📋Terminal Cheatsheet & Quick Reference
Every command you need in one place — bookmark this lesson
Terminal Cheatsheet & Quick Reference
Welcome to your ultimate terminal reference guide. This lesson brings together every command you have learned throughout this module into organized, easy-to-scan tables. Bookmark this page — you will come back to it often.
Tip: You do not need to memorize every command. The best developers look things up all the time. What matters is knowing what is possible and where to find the answer quickly.
How to Read These Tables
Each table follows this format:
| Column | Meaning |
|---|---|
| Command | The Mac/Linux terminal command |
| Windows Equivalent | The corresponding PowerShell or CMD command |
| Description | What the command does |
| Example | A practical usage example |
1. Navigation Commands
These commands help you move around the file system with confidence.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
pwd | cd (no args) | Print the current working directory | pwd → /Users/you/projects |
ls | dir | List files and folders in the current directory | ls |
ls -la | dir /a | List all files including hidden ones, with details | ls -la |
ls -lh | dir | List files with human-readable sizes | ls -lh |
ls -R | dir /s | List files recursively in subdirectories | ls -R src/ |
cd <dir> | cd <dir> | Change directory to the specified path | cd Documents/projects |
cd .. | cd .. | Go up one directory level | cd .. |
cd ~ | cd %USERPROFILE% | Go to your home directory | cd ~ |
cd - | N/A | Go back to the previous directory | cd - |
cd / | cd \ | Go to the root directory | cd / |
Navigation Pro Tips
- Use
cdfollowed by dragging a folder into the terminal to auto-fill the path. - Type the first few letters of a directory name and press Tab to autocomplete.
- Use
pushdandpopdto maintain a directory stack for quick back-and-forth navigation.
2. File Operations
The bread and butter of terminal work — creating, copying, moving, and deleting files.
Creating Files
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
touch <file> | New-Item <file> | Create an empty file or update its timestamp | touch index.html |
touch file1 file2 file3 | New-Item file1, file2, file3 | Create multiple files at once | touch app.js style.css |
mkdir <dir> | mkdir <dir> | Create a new directory | mkdir components |
mkdir -p a/b/c | mkdir -p a/b/c (PowerShell) | Create nested directories at once | mkdir -p src/components/ui |
Copying Files
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
cp <src> <dest> | copy <src> <dest> | Copy a file to a new location | cp config.json config.backup.json |
cp -r <src> <dest> | xcopy <src> <dest> /s | Copy a directory and all its contents recursively | cp -r templates/ my-project/ |
cp -i <src> <dest> | N/A | Copy with confirmation before overwriting | cp -i important.txt backup/ |
Moving and Renaming Files
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
mv <src> <dest> | move <src> <dest> | Move a file or directory to a new location | mv report.pdf Documents/ |
mv <old> <new> | ren <old> <new> | Rename a file or directory | mv oldname.js newname.js |
mv -i <src> <dest> | N/A | Move with confirmation before overwriting | mv -i data.csv archive/ |
Deleting Files
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
rm <file> | del <file> | Delete a file permanently | rm temp.log |
rm -r <dir> | rmdir /s <dir> | Delete a directory and all its contents | rm -r old-project/ |
rm -i <file> | N/A | Delete with confirmation prompt | rm -i important.doc |
rm -rf <dir> | rmdir /s /q <dir> | Force delete without confirmation (use with caution!) | rm -rf node_modules/ |
Warning:
rmdoes not move files to Trash. They are gone permanently. Always double-check before runningrm -rf.
Reading Files
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
cat <file> | type <file> | Display the entire contents of a file | cat README.md |
head <file> | Get-Content <file> -Head 10 | Display the first 10 lines of a file | head server.log |
head -n 20 <file> | Get-Content <file> -Head 20 | Display the first 20 lines of a file | head -n 20 data.csv |
tail <file> | Get-Content <file> -Tail 10 | Display the last 10 lines of a file | tail error.log |
tail -n 50 <file> | Get-Content <file> -Tail 50 | Display the last 50 lines of a file | tail -n 50 access.log |
tail -f <file> | Get-Content <file> -Wait | Follow a file in real time (great for logs) | tail -f server.log |
less <file> | more <file> | View file contents page by page (scrollable) | less package.json |
wc -l <file> | (Get-Content <file>).Length | Count the number of lines in a file | wc -l index.js |
3. Search Commands
Find files and content across your entire system or project.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
find . -name "*.js" | dir /s *.js | Find files by name pattern in current directory tree | find . -name "*.ts" |
find . -type f | dir /s /a:-d | Find only files (not directories) | find . -type f -name "*.md" |
find . -type d | dir /s /a:d | Find only directories | find . -type d -name "node_modules" |
find . -mtime -7 | N/A | Find files modified in the last 7 days | find . -mtime -7 -name "*.log" |
find . -size +10M | N/A | Find files larger than 10 megabytes | find . -size +10M |
grep "text" <file> | findstr "text" <file> | Search for a text pattern inside a file | grep "error" server.log |
grep -r "text" <dir> | findstr /s "text" <dir>/* | Search recursively through all files in a directory | grep -r "TODO" src/ |
grep -i "text" <file> | findstr /i "text" <file> | Case-insensitive search | grep -i "warning" output.log |
grep -n "text" <file> | findstr /n "text" <file> | Show line numbers with matches | grep -n "function" app.js |
grep -c "text" <file> | N/A | Count the number of matching lines | grep -c "error" server.log |
grep -l "text" *.js | N/A | List only file names that contain the match | grep -l "import" *.ts |
which <cmd> | where <cmd> | Show the full path of a command executable | which node |
whereis <cmd> | where <cmd> | Locate binary, source, and man page for a command | whereis python |
Search Pro Tips
- Combine
findwithgrep:find . -name "*.js" -exec grep -l "useState" {} \; - Use
grep -rntogether to get both recursive search and line numbers. - Modern alternative:
ripgrep(rg) is much faster thangrepfor large projects.
4. Permissions Commands
Control who can read, write, and execute files.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
chmod +x <file> | N/A | Make a file executable | chmod +x deploy.sh |
chmod 755 <file> | N/A | Set rwx for owner, rx for group and others | chmod 755 script.sh |
chmod 644 <file> | N/A | Set rw for owner, read-only for group and others | chmod 644 config.json |
chmod -R 755 <dir> | N/A | Apply permissions recursively to a directory | chmod -R 755 public/ |
chown <user> <file> | icacls <file> /setowner <user> | Change the owner of a file | chown admin server.conf |
chown -R <user>:<group> <dir> | N/A | Change owner and group recursively | chown -R www-data:www-data /var/www |
sudo <command> | Run as Administrator | Execute a command with superuser privileges | sudo apt update |
sudo -i | N/A | Open an interactive root shell | sudo -i |
ls -la | icacls <file> | View file permissions in the listing | ls -la config/ |
Permission Number Reference
| Number | Permission | Symbol |
|---|---|---|
| 0 | No permission | --- |
| 1 | Execute only | --x |
| 2 | Write only | -w- |
| 3 | Write + Execute | -wx |
| 4 | Read only | r-- |
| 5 | Read + Execute | r-x |
| 6 | Read + Write | rw- |
| 7 | Read + Write + Execute | rwx |
Common patterns:
755for scripts,644for config files,600for private keys.
5. System Commands
General-purpose commands for system information and daily terminal life.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
echo "text" | echo text | Print text to the terminal | echo "Hello World" |
echo $VARIABLE | echo %VARIABLE% | Print the value of an environment variable | echo $HOME |
clear | cls | Clear the terminal screen | clear |
history | doskey /history | Show a list of previously executed commands | history |
| `history | grep "git"` | `doskey /history | findstr "git"` |
man <cmd> | <cmd> --help or help <cmd> | Open the manual page for a command | man grep |
<cmd> --help | <cmd> /? | Show quick help for a command | git --help |
whoami | whoami | Display the current username | whoami |
date | date /t | Display the current date and time | date |
cal | N/A | Display a calendar for the current month | cal |
uptime | `systeminfo | find "Boot Time"` | Show how long the system has been running |
df -h | Get-PSDrive | Display disk space usage in human-readable format | df -h |
du -sh <dir> | `(Get-ChildItem -Recurse | Measure Length -Sum)` | Show the total size of a directory |
du -sh * | N/A | Show size of each item in the current directory | du -sh * |
top | tasklist | Display running processes in real time | top |
htop | taskmgr | Interactive process viewer (enhanced top) | htop |
ps aux | tasklist | List all running processes | ps aux |
kill <PID> | taskkill /PID <PID> | Terminate a process by its ID | kill 12345 |
killall <name> | taskkill /IM <name> | Terminate all processes by name | killall node |
6. Networking Commands
Test connections, download files, and work with remote servers.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
ping <host> | ping <host> | Test network connectivity to a host | ping google.com |
ping -c 5 <host> | ping -n 5 <host> | Send a specific number of ping requests | ping -c 5 api.example.com |
curl <url> | Invoke-WebRequest <url> | Transfer data from or to a server | curl https://api.github.com |
curl -o <file> <url> | Invoke-WebRequest -OutFile <file> <url> | Download a file and save with a specific name | curl -o data.json https://api.example.com/data |
curl -I <url> | N/A | Fetch only the HTTP headers | curl -I https://example.com |
curl -X POST -d '{"key":"val"}' <url> | Invoke-RestMethod -Method POST | Send a POST request with data | curl -X POST -d '{"name":"test"}' http://localhost:3000/api |
wget <url> | Invoke-WebRequest -OutFile | Download a file from the internet | wget https://example.com/file.zip |
wget -r <url> | N/A | Download an entire website recursively | wget -r https://docs.example.com |
ssh <user>@<host> | ssh <user>@<host> | Connect to a remote server via SSH | ssh deploy@192.168.1.100 |
ssh -p <port> <user>@<host> | ssh -p <port> <user>@<host> | Connect to SSH on a non-default port | ssh -p 2222 admin@server.com |
scp <file> <user>@<host>:<path> | scp <file> <user>@<host>:<path> | Securely copy files to a remote server | scp build.zip deploy@server:/var/www/ |
ifconfig / ip addr | ipconfig | Show network interface information | ifconfig |
netstat -an | netstat -an | Show active network connections and ports | `netstat -an |
lsof -i :<port> | `netstat -ano | findstr :<port>` | Find which process is using a specific port |
7. Keyboard Shortcuts
Speed up your workflow dramatically with these shortcuts.
| Shortcut | Windows Terminal Equivalent | Description |
|---|---|---|
| Tab | Tab | Autocomplete file and directory names |
| Tab Tab | Tab Tab | Show all possible completions |
| Ctrl + C | Ctrl + C | Cancel the current running command |
| Ctrl + D | Ctrl + D | Exit the current shell session |
| Ctrl + Z | N/A | Suspend the current process (resume with fg) |
| Ctrl + L | Ctrl + L | Clear the terminal screen (same as clear) |
| Ctrl + R | Ctrl + R | Reverse search through command history |
| Ctrl + A | Home | Move cursor to the beginning of the line |
| Ctrl + E | End | Move cursor to the end of the line |
| Ctrl + W | Ctrl + Backspace | Delete the word before the cursor |
| Ctrl + U | N/A | Delete everything before the cursor |
| Ctrl + K | N/A | Delete everything after the cursor |
| Ctrl + Y | N/A | Paste the last deleted text |
| Alt + B | Ctrl + Left | Move cursor back one word |
| Alt + F | Ctrl + Right | Move cursor forward one word |
| Up Arrow | Up Arrow | Recall the previous command from history |
| Down Arrow | Down Arrow | Go forward in command history |
| !! | N/A | Repeat the last command |
| !$ | N/A | Use the last argument of the previous command |
| Ctrl + Shift + C | Ctrl + Shift + C | Copy selected text in terminal |
| Ctrl + Shift + V | Ctrl + Shift + V | Paste text into terminal |
8. Package Managers
Install and manage software from the command line.
System Package Managers
| Command | Platform | Description | Example |
|---|---|---|---|
brew install <pkg> | macOS | Install a package via Homebrew | brew install git |
brew update | macOS | Update Homebrew package list | brew update |
brew upgrade | macOS | Upgrade all installed packages | brew upgrade |
brew list | macOS | List all installed Homebrew packages | brew list |
brew uninstall <pkg> | macOS | Remove a Homebrew package | brew uninstall wget |
brew search <pkg> | macOS | Search for a package in Homebrew | brew search python |
apt update | Linux (Debian/Ubuntu) | Update the package index | sudo apt update |
apt install <pkg> | Linux (Debian/Ubuntu) | Install a package | sudo apt install nodejs |
apt upgrade | Linux (Debian/Ubuntu) | Upgrade all installed packages | sudo apt upgrade |
apt remove <pkg> | Linux (Debian/Ubuntu) | Remove a package | sudo apt remove firefox |
apt search <pkg> | Linux (Debian/Ubuntu) | Search for a package | apt search python3 |
apt list --installed | Linux (Debian/Ubuntu) | List all installed packages | apt list --installed |
Developer Package Managers
| Command | Ecosystem | Description | Example |
|---|---|---|---|
npm install <pkg> | Node.js | Install a Node.js package locally | npm install express |
npm install -g <pkg> | Node.js | Install a Node.js package globally | npm install -g typescript |
npm init -y | Node.js | Initialize a new Node.js project | npm init -y |
npm run <script> | Node.js | Run a script defined in package.json | npm run build |
npm list | Node.js | List installed packages | npm list --depth=0 |
npm uninstall <pkg> | Node.js | Remove a package | npm uninstall lodash |
npm outdated | Node.js | Check for outdated packages | npm outdated |
pip install <pkg> | Python | Install a Python package | pip install requests |
pip install -r requirements.txt | Python | Install packages from a requirements file | pip install -r requirements.txt |
pip list | Python | List installed Python packages | pip list |
pip uninstall <pkg> | Python | Remove a Python package | pip uninstall flask |
pip freeze | Python | Output installed packages in requirements format | pip freeze > requirements.txt |
Windows Package Manager
| Command | Description | Example |
|---|---|---|
choco install <pkg> | Install a package via Chocolatey | choco install git |
choco upgrade all | Upgrade all Chocolatey packages | choco upgrade all |
winget install <pkg> | Install a package via Windows Package Manager | winget install Microsoft.VisualStudioCode |
winget upgrade --all | Upgrade all winget packages | winget upgrade --all |
9. Environment Variables
Configure your shell environment and manage variables.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
export VAR=value | set VAR=value | Set an environment variable for the current session | export NODE_ENV=production |
export PATH=$PATH:/new/path | set PATH=%PATH%;C:\new\path | Add a directory to the PATH | export PATH=$PATH:$HOME/.local/bin |
echo $VAR | echo %VAR% | Display the value of a variable | echo $HOME |
echo $PATH | echo %PATH% | Display the current PATH | echo $PATH |
env | set | List all environment variables | env |
printenv VAR | echo %VAR% | Print a specific environment variable | printenv HOME |
unset VAR | set VAR= | Remove an environment variable | unset DEBUG |
source ~/.bashrc | N/A | Reload the shell configuration file | source ~/.zshrc |
source .env | N/A | Load variables from a .env file into the session | source .env |
. ~/.profile | N/A | Alternative syntax for source | . ~/.bash_profile |
Making Variables Permanent
To keep environment variables across sessions, add them to your shell configuration file:
- Bash: Add
export VAR=valueto~/.bashrcor~/.bash_profile - Zsh: Add
export VAR=valueto~/.zshrc - Windows: Use System Properties > Environment Variables, or
setx VAR valuein CMD
10. Redirection & Piping
Combine commands and control input/output like a pro.
| Command | Windows Equivalent | Description | Example |
|---|---|---|---|
cmd > file | cmd > file | Redirect output to a file (overwrite) | echo "hello" > greeting.txt |
cmd >> file | cmd >> file | Append output to a file | echo "world" >> greeting.txt |
cmd 2> file | cmd 2> file | Redirect error output to a file | node app.js 2> errors.log |
cmd &> file | cmd > file 2>&1 | Redirect both stdout and stderr to a file | npm build &> build.log |
| `cmd1 | cmd2` | `cmd1 | cmd2` |
cmd1 && cmd2 | cmd1 && cmd2 | Run cmd2 only if cmd1 succeeds | npm test && npm run build |
| `cmd1 | cmd2` | `cmd1 | |
cmd1 ; cmd2 | cmd1 & cmd2 | Run cmd2 after cmd1 regardless of success | mkdir dist ; cp files dist/ |
Quick Reference Card
The 10 Commands You Will Use Every Day
| # | Command | What It Does |
|---|---|---|
| 1 | cd <dir> | Navigate to a directory |
| 2 | ls -la | See what is in the current directory |
| 3 | cat <file> | Read a file quickly |
| 4 | touch <file> | Create a new file |
| 5 | mkdir <dir> | Create a new directory |
| 6 | cp <src> <dest> | Copy a file |
| 7 | mv <src> <dest> | Move or rename a file |
| 8 | rm <file> | Delete a file |
| 9 | grep "text" <file> | Search inside a file |
| 10 | history | See what you ran before |
The 5 Shortcuts That Save the Most Time
| # | Shortcut | What It Does |
|---|---|---|
| 1 | Tab | Autocomplete — stops typos |
| 2 | Ctrl + C | Cancel — your emergency exit |
| 3 | Ctrl + R | Search history — find old commands instantly |
| 4 | Up Arrow | Recall — repeat last commands |
| 5 | Ctrl + L | Clear — clean slate for focus |
What Comes Next
Congratulations! You have completed the Terminal & Command Line module. You now have a solid foundation in:
- Navigating the file system with confidence
- Creating, copying, moving, and deleting files
- Searching for files and content
- Managing permissions and using sudo
- Monitoring system resources
- Working with networking tools
- Using keyboard shortcuts for speed
- Managing packages across platforms
- Configuring environment variables
You are ready for Claude Code CLI! In the next module, you will put these terminal skills to work by learning the Claude Code command-line interface — the tool that brings AI-powered coding directly into your terminal workflow. Everything you learned here will make that experience smooth and productive.
Remember: This cheatsheet is always here for you. Come back whenever you need a quick refresher. The best developers are not the ones who memorize everything — they are the ones who know where to find the answer.