Foundations Module 4 · Cheat Sheets
Linux Commands Reference
A printable cheat sheet of essential terminal commands
💡Bookmark this page
This is a reference page — you don’t need to memorize everything here. Bookmark it and come back whenever you need to look up a command. You can also click “Print” to get a paper copy.
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 & 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 |
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 -20 log.txt |
tail file | Show last 10 lines | 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" |
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'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) |
brew install package | Install via Homebrew | macOS / Linux |
apt install package | Install via APT | Ubuntu / Debian |
winget install package | Install via Windows Package Manager | Windows |
Permissions & Sudo
Running commands with elevated privileges
| Command | What it does | Example |
|---|---|---|
sudo command | Run as administrator | sudo npm install -g claude |
chmod +x file | Make a file executable | chmod +x script.sh |
chown user file | Change file ownership | chown user:group file |
ℹYou don't need all of these
The commands from Module 3 (pwd, ls, cd, mkdir, touch, cat, cp, mv, rm) cover 90% of what you’ll do. The rest of this cheat sheet is here for when you need it — which usually means when an AI tool suggests a command and you want to understand what it does.