Terminal Commands Reference
Last reviewed
BeginnerWhat you'll learn
~10 min- Look up any common terminal command quickly
- Navigate the filesystem, manage files, and search for content
- Understand what a command does before running it
- Use package managers to install CLI tools
- Translate a command between Bash/Zsh and Windows PowerShell
By the end of this lesson, you will have a reliable reference for every terminal command you are likely to need during this course. You do not need to memorize any of this — the goal is to know where to look.
Bookmark this page. You don’t need to memorize these commands — come back whenever you forget one. Use Ctrl+F (or Cmd+F on Mac) to search for what you need.
Mental model: the terminal is a filing cabinet
Think of your computer’s filesystem like a giant filing cabinet. Each drawer is a folder, each paper inside is a file. Terminal commands are just instructions like “open this drawer,” “move that paper,” or “find every paper with the word budget in it.” You already know how to do these things with a mouse — the terminal is simply a faster way to say the same thing out loud.
The tables below use Bash/Zsh, the shells on macOS, Linux, WSL, and Codespaces. Windows PowerShell understands many of the same names, and the next table shows where it differs. Some GNU flags also behave differently on macOS: for example, sed -i needs sed -i '' there.
Bash/Zsh and Windows PowerShell side by side
These everyday commands work with the same name in both: pwd, ls, cd, mkdir, cat, cp, mv, rm, clear, echo, whoami, and history. The flags after the name are where they part ways.
Bash/Zsh vs PowerShell
Same task, two shells
| Task | Bash/Zsh (macOS, Linux, WSL) | Windows PowerShell |
|---|---|---|
| Where am I? | pwd | pwd |
| List files, including hidden | ls -la | ls -Force |
| Make nested folders | mkdir -p a/b/c | mkdir a/b/c (creates the whole chain) |
| Create an empty file | touch notes.txt | New-Item notes.txt (there is no touch) |
| Copy or delete a folder | cp -r src dest, rm -r old | cp -Recurse src dest, rm -Recurse old |
| First or last lines of a file | head log.txt, tail log.txt | Get-Content log.txt -Head 10, Get-Content log.txt -Tail 10 |
| Search inside files | grep "error" log.txt | Select-String "error" log.txt |
| Find where a program lives | which node | where.exe node (or Get-Command node) |
| Set a variable for this session | export NAME="val" | $env:NAME="val" |
| Install software | brew install git (macOS), sudo apt install git (Ubuntu) | winget install Git.Git |
| Run as administrator | sudo command | Right-click the terminal, then Run as administrator |
| Get help on a command | man ls or ls --help | Get-Help ls |
In PowerShell, plain where is a shortcut for a different command that filters lists, so it prints nothing useful. Include the .exe.
Navigation
Moving around the filesystem.
Navigation
Moving around the filesystem
| Command | What it does | Example |
|---|---|---|
pwd | Print current directory | pwd → /home/user |
ls | List directory contents | ls |
ls -la | List all files (including hidden) with details | ls -la |
cd folder | Change into a directory | cd projects |
cd .. | Go up one directory | cd .. |
cd ~ | Go to home directory | cd ~ |
cd - | Go to previous directory | cd - |
Files and folders
Creating, copying, moving, and deleting.
Files & Folders
Creating, copying, moving, deleting
| Command | What it does | Example |
|---|---|---|
mkdir name | Create a directory | mkdir my-project |
mkdir -p a/b/c | Create nested directories | mkdir -p src/components/ui |
touch file | Create an empty file (Bash/Zsh; PowerShell: New-Item file) | touch index.html |
cp src dest | Copy a file | cp file.txt backup.txt |
cp -r src dest | Copy a folder recursively | cp -r project project-backup |
mv src dest | Move or rename | mv old.txt new.txt |
rm file | Delete a file (permanent!) | rm temp.txt |
rm -r folder | Delete a folder recursively | rm -r old-project |
Unlike dragging something to the Trash on your desktop, rm does not have an undo. There is no recycling bin. Double-check your command before pressing Enter, especially with rm -r.
Reading and searching
Viewing file contents and finding things.
Reading & Searching
Viewing file contents and finding things
| Command | What it does | Example |
|---|---|---|
cat file | Print file contents | cat README.md |
head file | Show first 10 lines | head log.txt |
head -n 20 file | Show first 20 lines | head -n 20 log.txt |
tail file | Show last 10 lines | tail server.log |
tail -f file | Follow live updates (Ctrl+C to stop) | tail -f server.log |
less file | Scroll through a file (q to quit) | less long-file.txt |
grep pattern file | Search for text in a file | grep "error" log.txt |
grep -r pattern dir | Search recursively in directory | grep -r "TODO" src/ |
find dir -name pattern | Find files by name | find . -name "*.js" |
🧬In Your Field: Biotechclick to expand
Working with sequencing data or large CSV exports? Use head -5 results.csv to peek at just the first five lines. For FASTA files, grep -c '>' sequences.fasta counts how many sequences are in the file. These quick checks save you from opening a 2 GB file in Excel.
📊In Your Field: MIS / Businessclick to expand
Dealing with exported reports or database dumps? grep "2026-01" transactions.csv pulls out every line from January 2026. Combine it with wc -l to count matches: grep "2026-01" transactions.csv | wc -l tells you how many January transactions you have.
🏛️In Your Field: Government Devclick to expand
Government projects often involve searching through configuration files or logs. grep -r "API_KEY" . searches every file in the current directory for the text “API_KEY” — useful when you need to find where a setting lives across a complex project.
System info
Learning about your environment.
System Info
Learning about your environment
| Command | What it does | Example |
|---|---|---|
whoami | Print your username | whoami → user |
which command | Show where a command lives (PowerShell: where.exe command) | which node → /home/user/.nvm/versions/node/v22.x.x/bin/node |
echo text | Print text to screen | echo "hello" |
date | Show current date/time | date |
clear | Clear the terminal screen | clear |
history | Show command history | history |
Package managers
Installing software (you will need these for CLI tools).
Package Managers
Installing software (you'll need these for CLI tools)
| Command | What it does | Platform |
|---|---|---|
npm install -g <package> | Install a Node.js package globally | All (needs Node.js) |
npx <command> | Run a package without installing | All (needs Node.js) |
pip install <package> | Install a Python package (on Ubuntu/WSL, inside a virtual environment: python3 -m venv .venv then source .venv/bin/activate) | All (needs Python) |
brew install <package> | Install via Homebrew | macOS / Linux |
sudo apt update, then sudo apt install <package> | Install via APT (run as two separate commands) | Ubuntu / Debian / WSL |
winget install <package> | Install via Windows Package Manager | Windows (PowerShell) |
Getting help
When you forget how a command works, the terminal can help you.
Getting Help
How to look up command usage from the terminal
| Command | What it does | Example |
|---|---|---|
man <command> | Open the manual page for a command (press q to quit; PowerShell: Get-Help) | man grep |
<command> --help | Show a brief usage summary | ls --help |
which <command> | Show where a command is installed (PowerShell: where.exe) | which node |
command -v <command> | Check if a command exists (portable alternative to which) | command -v python3 |
Man pages can look overwhelming at first. Focus on the SYNOPSIS (how to call the command) and DESCRIPTION (what it does). Scroll with arrow keys or Page Up/Down. Press / to search within the page, and q to quit.
Permissions and sudo
Running commands with elevated privileges.
Permissions & Sudo
Running commands with elevated privileges
| Command | What it does | Example |
|---|---|---|
sudo command | Run as administrator (Linux/macOS/WSL; it asks for your password, which stays invisible as you type) | sudo apt install git |
chmod +x file | Make a file executable | chmod +x script.sh |
chown user[:group] file | Change file ownership | chown user:group file |
When things go wrong
Common problems and quick fixes:
| Problem | Quick fix |
|---|---|
| Command is stuck / hanging | Press Ctrl+C to interrupt |
Stuck in a pager (: prompt) | Press q to quit |
command not found | Check spelling, verify install with which <command> (PowerShell: where.exe <command>) |
| Wrong folder | Run pwd then ls to orient yourself |
| Permission denied | Check if you need sudo (for system commands) or if you’re in the wrong directory |
| Need help with a command | Run <command> --help or man <command> |
When Things Go Wrong
Use the Symptom → Evidence → Request pattern: describe what you see, paste the error, then ask for a fix.
Key takeaways
- A handful of commands cover most daily work:
pwd,ls,cd,mkdir,cat,cp,mv,rm, andgrep(Select-Stringin PowerShell). Most of them share a name across Bash, Zsh, and PowerShell. - Bookmark this page rather than trying to memorize it. Even experienced developers look things up constantly.
- When an AI tool suggests a command you don’t recognize, come back here to understand what it does before running it.
rmis permanent — always double-check before deleting.
🔍Going further with the command lineclick to expand
If you want to go deeper, look into these topics on your own time:
- Piping (
|): chain commands together, likecat file.txt | grep "error" | wc -l(count error lines) - Redirection (
>,>>): send output to a file instead of the screen - Aliases: create shortcuts for long commands you use often
- Shell scripts: save a sequence of commands in a
.shfile and run them all at once
None of these are required for this course, but they can make your workflow even faster.