Linux Commands Reference
What 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
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.
Most commands below are POSIX-style (Linux/macOS, or WSL/Git Bash on Windows). Windows-native alternatives are noted where needed. Some GNU flags may behave differently on macOS — for example, sed -i requires sed -i '' on macOS.
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 | 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 / State 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 | which node → /usr/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 | All (needs Python) |
brew install <package> | Install via Homebrew | macOS / Linux |
sudo apt update && sudo apt install <package> | Install via APT | Ubuntu / Debian |
winget install <package> | Install via Windows Package Manager | Windows |
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) | man grep |
<command> --help | Show a brief usage summary | ls --help |
which <command> | Show where a command is installed | 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 | 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> or command -v <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
- You only need about 10 commands for 90% of your work:
pwd,ls,cd,mkdir,touch,cat,cp,mv,rm, andgrep. - 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 line
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.