Command Line Cheat Sheet

Free terminal cheat sheet: navigation, file management, grep, pipes, redirects, and process commands at a glance.

ConceptSyntaxExample
Where am I?
Prints the current directory path.
pwdpwd → /home/ada/projects
List files
-l long format, -a includes hidden files (dotfiles).
ls -lals -la
Change directory
cd .. goes up one level; plain cd goes home.
cd <path>cd projects/app
Find files
Searches recursively from the given directory.
find <dir> -name <pattern>find . -name "*.js"

Learn it in a lesson: File System Navigation · Finding Files with find and xargs

Files & Folders

ConceptSyntaxExample
Create
-p creates the whole nested path at once.
touch <file> / mkdir -p <dir>mkdir -p src/components
Copy / Move
-r is needed to copy directories. mv also renames.
cp -r / mvcp -r src backup/
Delete
⚠️ There is no recycle bin — rm is permanent.
rm <file> / rm -r <dir>rm -r old-build
View a file
less scrolls; tail -f follows a growing log live.
cat, less, head, tailtail -n 50 app.log

Learn it in a lesson: File Management Commands

Search & Text

ConceptSyntaxExample
Search in files
-n shows line numbers, -i ignores case.
grep -r "text" <dir>grep -rn "TODO" src/
Pipes
Sends one command's output into the next — the shell's superpower.
cmd1 | cmd2history | grep git
Redirect output
2>&1 sends errors to the same place as normal output.
> overwrite, >> appendnode app.js > out.log 2>&1
Count things
Counts lines — combine with pipes to count anything.
wc -lls | wc -l

Learn it in a lesson: Pipes and Redirection · Text Processing with grep, sed, awk · Redirection and File Descriptors

Power Moves

ConceptSyntaxExample
Stop a program
Ctrl+Z suspends instead; fg resumes it.
Ctrl+C(stops the running process)
Rerun & history
!! repeats the last command — handy after forgetting sudo.
history, !!, ↑sudo !!
Permissions
Makes a script executable so ./deploy.sh runs.
chmod +x <file>chmod +x deploy.sh
Processes
Find a process and stop it; -9 is the forceful version.
ps aux | grep <name>, kill <pid>kill -9 12345

Learn it in a lesson: Process Management · Permissions and Users

Finding Things

ConceptSyntaxExample
Find files by name
Quote the pattern or the shell expands it before find sees it.
find . -name '*.log'find . -name '*.log' -mtime -1
Search inside files
-r recurses, -n gives line numbers, -i ignores case.
grep -rn 'text' .grep -rn 'TODO' src/
Only matching partgrep -ogrep -o 'v[0-9.]*' file
Which command is thiswhich / typewhich python3
Search historyCtrl+RCtrl+R then type part of an old command

Learn it in a lesson: Finding Files with find and xargs · Text Processing with grep, sed, awk · Environment Variables

Pipes & Redirection

ConceptSyntaxExample
Pipe
Sends a's stdout into b's stdin.
a | bps aux | grep node
Write to a file
> truncates the file, >> appends. The difference has cost people work.
> file | >> fileecho hi > out.txt
Errors too
stderr is a separate stream and is NOT piped unless you redirect it.
2>&1make 2>&1 | tee build.log
Discard output> /dev/nullcommand > /dev/null 2>&1
See and saveteenpm test | tee test.log
Count lineswc -lgrep -c 'error' log.txt

Learn it in a lesson: Pipes and Redirection · Redirection and File Descriptors

Text Processing

ConceptSyntaxExample
Pick a columncut -d',' -f2 | awk '{print $2}'awk -F',' '{print $2}' data.csv
Replace text
Add -i to edit the file in place — and make a backup first.
sed 's/old/new/g'sed 's/foo/bar/g' file.txt
Sort and dedupe
uniq only removes ADJACENT duplicates, which is why sort comes first.
sort | uniq -csort words.txt | uniq -c | sort -rn | head
First or last lines
-f follows the file as it grows.
head -n / tail -ntail -f app.log

Learn it in a lesson: Text Processing with grep, sed, awk

Permissions & Jobs

ConceptSyntaxExample
Make executablechmod +x filechmod +x deploy.sh
Run in the backgroundcommand &npm run dev &
Keep running after logoutnohup command &nohup ./worker.sh &
Stop a commandCtrl+CCtrl+C sends SIGINT to the foreground job
Chain on success
&& only runs b if a succeeded; ; runs b either way.
a && bnpm test && npm run build

Learn it in a lesson: Process Management · Permissions and Users · Pipes and Redirection