Working with files and directories
| Command | Description |
|---|
| ls | list files |
| cd dir | change directory to dir |
| cd | change to home directory |
| pwd | print name of current working directory |
| mkdir dir | create a directory called dir |
| rmdir dir | remove directory dir. Note that the directory must be empty for this command to work. |
| rm -r dir | remove directory dir and all the files in it. |
| cp file1 file2 | copy file1 to file2 |
| cp -r dir1 dir2 | copy contents of dir1 to dir2 recursively |
| mv file1 file2 | move or rename file1 to file2. If file2 is an existing directory, moves file1 into file2 directory. |
| rm file1 | remove the file1 file |
| cat file | display the contents of file in the terminal window |
| more file | display the contents of file in the terminal window one screen at a time |
| less file | display the contents of file in the terminal window one screen at a time |
| head file | display the first 10 lines of file |
| head -n N file | display the first N lines of file |
| tail file | display the last 10 lines of file |
| tail -f file | display 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.
| Command | Description |
|---|
| CTRL+C | kills the current process |
| CTRL+Z | suspends the current process by putting it into the background. Resume with the fg command. |
| CTRL+D | log out of current session. Similar to the exit command. |
| CTRL+A | move cursor to beginning of line |
| CTR+E | move cursot to end of line |
| CTRL+L | clear the screen. Similar to the clear command. |
| exit | log out of the current session |
| clear | clear the screen |
| history | display your command history |
| up arrow | go back through your command history |
System info
| Command | Description |
|---|
| date | show the current date and time |
| cal | show current month's calendar |
| whoami | who you are logged in as |
| w | who is logged in on the host |
| which cmd | find filesystem location of cmd |
| whereis cmd | locate binaries, source, and man pages for cmd |
| free | show amount of free and used memory on system |
Getting help
| Command | Description |
|---|
| man cmd | show the manual page for the command cmd |
| info cmd | show the info page for the command cmd |
| apropos keyword | search the manual pages for keyword |
| man -k keyword | same as 'apropos keyword' |
| whatis keyword | display one-line manual page description for keyword |