Terminal Cheat Sheet
A comprehensive reference for every command and shortcut covered in the course. Click “Save as PDF” to download.
Navigation
| pwd | Print working directory (where am I?) |
| cd dirname | Change into a directory |
| cd .. | Go up one level |
| cd ~ | Go to home directory |
| cd - | Go to previous directory |
| cd / | Go to root directory |
| ls | List files in current directory |
| ls -l | Long format (permissions, size, date) |
| ls -a | Show hidden files (dotfiles) |
| ls -la | Long format + hidden files |
| ls -R | List recursively (all subdirectories) |
File Operations
| touch file.txt | Create an empty file |
| mkdir dirname | Create a directory |
| mkdir -p a/b/c | Create nested directories |
| cp source dest | Copy a file |
| cp -r srcdir/ destdir/ | Copy a directory recursively |
| mv oldname newname | Rename (or move) a file |
| mv file.txt dir/ | Move file into a directory |
| rm file.txt | Delete a file (permanent!) |
| rm -r dirname/ | Delete a directory and contents |
| rmdir empty-dir/ | Delete an empty directory only |
Viewing Files
| cat file.txt | Print entire file |
| head file.txt | Print first 10 lines |
| head -n 5 file.txt | Print first 5 lines |
| tail file.txt | Print last 10 lines |
| tail -n 5 file.txt | Print last 5 lines |
| less file.txt | Scrollable file viewer (q to quit) |
Keyboard Shortcuts
| Tab | Autocomplete file/command names |
| Up Arrow | Previous command from history |
| Ctrl + C | Cancel current command |
| Ctrl + L | Clear the screen |
| Ctrl + A | Jump to beginning of line |
| Ctrl + E | Jump to end of line |
| Ctrl + W | Delete word before cursor |
| Ctrl + U | Delete from cursor to start of line |
| Ctrl + K | Delete from cursor to end of line |
| Ctrl + R | Reverse search command history |
| Alt + F | Move cursor forward one word |
| Alt + B | Move cursor backward one word |
Piping & Redirection
| command > file.txt | Redirect output to file (overwrite) |
| command >> file.txt | Append output to file |
| command1 | command2 | Pipe: send output to next command |
| grep "pattern" file | Search for text in a file |
| grep -i "pattern" file | Case-insensitive search |
| grep -c "pattern" file | Count matching lines |
| wc -l file.txt | Count lines |
| wc -w file.txt | Count words |
| sort file.txt | Sort lines alphabetically |
| sort -n file.txt | Sort numerically |
| uniq | Remove adjacent duplicate lines |
| uniq -c | Count occurrences of each line |
Search & Find
| find . -name "*.txt" | Find files by name pattern |
| find . -type d | Find directories only |
| which command | Show where a command is installed |
Environment Variables
| echo $HOME | Print home directory path |
| echo $PATH | Print executable search path |
| echo $USER | Print current username |
| export VAR="value" | Set an environment variable |
Power User
| *.txt | Wildcard: match any .txt files |
| file{1..5}.txt | Brace expansion: file1.txt through file5.txt |
| $(command) | Command substitution: use output as argument |
| cmd1 && cmd2 | Run cmd2 only if cmd1 succeeds |
| cmd1 || cmd2 | Run cmd2 only if cmd1 fails |
| !! | Repeat last command |
| !$ | Last argument of previous command |
| alias ll="ls -la" | Create a shortcut for a command |
Getting Help
| command --help | Quick usage summary |
| man command | Full manual page (q to quit) |
Terminal Velocity — terminalvelocitycourse.com