Command Line Cheat Sheet

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

Navigation

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"

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

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

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