Learning the Shell Flashcards
date
Outputs date and time per host settings
cal
Outputs calendar for the current month per host settings
df
Outputs the ‘disk free’ / the current amount of free space on your disk drives
ln
[ … how to create a hard link ]
[ … how to create a symbolic link ]
Creates hard and symbolic links
ln FILE LINK => creates a hard link
ln -s ITEM LINK => creates a symbolic link where ITEM is either a file or a directory
rm
Removes files and directories.
Note: use of the ‘-r’ may be required to remove directories on select Linux based OS’s.
mkdir
Creates directories
mv
Moves / Renames flies and directories
mv dir1/fun dir2 => moves the ‘fun’ file from directory 1 (‘dir1) to directory 2 (‘dir2’)
mv fun funner => changes the file / directory named ‘fun’ to ‘funner’
cp
Copies directories or files
cp dir1/fun dir2 => copies the ‘fun’ file in directory 1 (‘dir1’) to directory 2 (‘dir2’)
less
[ … navigation commands ]
View file contents within the command line interface.
Navigation commands:
b / PAGE UP : Scroll back one page
spacebar / PAGE DOWN : Scroll forward one page
up arrow : Scroll up one line
down arrow : Scroll down one line
G : Move to the end of the text file
1G or g : Move to the beginning of the text file
/characters : Search forward to the next occurrence of characters
n : Search for the next occurrence of the previous search
h : Display help screen
q : Quit less
file
Outputs the file type
file FILE
ls
Outputs a list of directory contents
pwd
Print Working Directory : outputs / prints the name of the current working directory
cd
Change Directory : Changes to the specified directory
On the desktop there is a folder named ‘dir1’
From Desktop : cd dir1 => moves the operator to the working directory to ‘dir1’
exit
bye
Exit or Bye can be used to end the terminal session
free
Outputs amount of free memory on the host
type
Outputs how a command name is interpreted
type ls => ‘ls is /bin/ls’
[ ^ from MacOS ]
which
Outputs which executable program will be executed
which ls => /bin/ls
[ ^ from MacOS ]
man
Outputs a command’s manual page – i.e. the detailed documentation of the command and its options
man COMMAND
apropos
Outputs a list of appropriate commands like a search function
apropos COMMAND
info
Outputs a command’s info entry
info COMMAND
whatis
Outputs a brief description of a command
whatis COMMAND
alias
Creates an alias for a command durable for the terminal session.
if ‘cd /user; ls; cd -‘ is a common line, then
alias foo=’cd /user; ls; cd -‘, then typing
‘foo’ will execute ‘cd /user; ls; cd-‘ for the remainder of the terminal session.
cat
Concatenates files
you have movie.mpeg.001 … movie.mpeg.099 =>
cat movie.mpeg.0* > movie.mpeg
^ concatenates the files into a single file
sort
Sort lines of text