Command Line Cheat Sheet
Free terminal cheat sheet: navigation, file management, grep, pipes, redirects, and process commands at a glance.
Navigation
| Concept | Syntax | Example |
|---|---|---|
| Where am I? Prints the current directory path. | pwd | pwd → /home/ada/projects |
| List files -l long format, -a includes hidden files (dotfiles). | ls -la | ls -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
| Concept | Syntax | Example |
|---|---|---|
| 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 / mv | cp -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, tail | tail -n 50 app.log |
Search & Text
| Concept | Syntax | Example |
|---|---|---|
| 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 | cmd2 | history | grep git |
| Redirect output 2>&1 sends errors to the same place as normal output. | > overwrite, >> append | node app.js > out.log 2>&1 |
| Count things Counts lines — combine with pipes to count anything. | wc -l | ls | wc -l |
Power Moves
| Concept | Syntax | Example |
|---|---|---|
| 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 |