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

CommandWhat it doesExample
pwdPrint current directorypwd/home/user
lsList directory contentsls
ls -laList all files (including hidden) with detailsls -la
cd folderChange into a directorycd projects
cd ..Go up one directorycd ..
cd ~Go to home directorycd ~
cd -Go to previous directorycd -

Files & Folders

Creating, copying, moving, deleting

CommandWhat it doesExample
mkdir nameCreate a directorymkdir my-project
mkdir -p a/b/cCreate nested directoriesmkdir -p src/components/ui
touch fileCreate an empty filetouch index.html
cp src destCopy a filecp file.txt backup.txt
cp -r src destCopy a folder recursivelycp -r project project-backup
mv src destMove or renamemv old.txt new.txt
rm fileDelete a file (permanent!)rm temp.txt
rm -r folderDelete a folder recursivelyrm -r old-project

Reading & Searching

Viewing file contents and finding things

CommandWhat it doesExample
cat filePrint file contentscat README.md
head fileShow first 10 lineshead -20 log.txt
tail fileShow last 10 linestail -f server.log
less fileScroll through a file (q to quit)less long-file.txt
grep pattern fileSearch for text in a filegrep "error" log.txt
grep -r pattern dirSearch recursively in directorygrep -r "TODO" src/
find dir -name patternFind files by namefind . -name "*.js"

System Info

Learning about your environment

CommandWhat it doesExample
whoamiPrint your usernamewhoamiuser
which commandShow where a command liveswhich node/usr/bin/node
echo textPrint text to screenecho "hello"
dateShow current date/timedate
clearClear the terminal screenclear
historyShow command historyhistory

Package Managers

Installing software (you'll need these for CLI tools)

CommandWhat it doesPlatform
npm install -g packageInstall a Node.js package globallyAll (needs Node.js)
npx commandRun a package without installingAll (needs Node.js)
brew install packageInstall via HomebrewmacOS / Linux
apt install packageInstall via APTUbuntu / Debian
winget install packageInstall via Windows Package ManagerWindows

Permissions & Sudo

Running commands with elevated privileges

CommandWhat it doesExample
sudo commandRun as administratorsudo npm install -g claude
chmod +x fileMake a file executablechmod +x script.sh
chown user fileChange file ownershipchown 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.