Linux Cheatsheet

Working with files and directories

CommandDescription
lslist files
cd dirchange directory to dir
cdchange to home directory
pwd                   print name of current working directory
mkdir dir     create a directory called dir
rmdir dirremove directory dir. Note that the directory must be empty for this command to work.
rm -r dirremove directory dir and all the files in it.
cp file1 file2copy file1 to file2
cp -r dir1 dir2copy contents of dir1 to dir2 recursively
mv file1 file2move or rename file1 to file2. If file2 is an existing directory, moves file1 into file2 directory.
rm file1remove the file1 file
cat filedisplay the contents of file in the terminal window
more filedisplay the contents of file in the terminal window one screen at a time
less filedisplay the contents of file in the terminal window one screen at a time
head filedisplay the first 10 lines of file
head -n N filedisplay the first N lines of file
tail filedisplay the last 10 lines of file
tail -f filedisplay the contents of file as it grows, starting with the last 10 lines

Keyboard shortcuts and miscellaneous commands

For the shortcut notation in the table below, CTRL+ means you should hold down the CTRL key and press the letter that follows the plus sign. For example, 'CTRL+C' means hold down the CRTL key and then press the 'c' key.

CommandDescription
CTRL+Ckills the current process
CTRL+Z            suspends the current process by putting it into the background. Resume with the fg command.
CTRL+Dlog out of current session. Similar to the exit command.
CTRL+Amove cursor to beginning of line
CTR+Emove cursot to end of line
CTRL+Lclear the screen. Similar to the clear command.
exitlog out of the current session
clearclear the screen
historydisplay your command history
up arrowgo back through your command history

System info

CommandDescription
dateshow the current date and time
calshow current month's calendar
whoamiwho you are logged in as
wwho is logged in on the host
which cmd  find filesystem location of cmd
whereis cmdlocate binaries, source, and man pages for cmd
free                    show amount of free and used memory on system

Getting help

CommandDescription
man cmdshow the manual page for the command cmd
info cmdshow the info page for the command cmd
apropos keywordsearch the manual pages for keyword
man -k keywordsame as 'apropos keyword'
whatis keyworddisplay one-line manual page description for keyword