Cheat sheetDev
Terminal basics
The terminal commands you'll actually use daily — navigation, files, search, pipes, and process control in one page.
Last updated
Moving around
| Command | What it does |
|---|---|
| pwd | Prints where you actually are — the answer once relative paths stop making sense. |
| ls -la | Lists hidden dotfiles and permissions too — plain ls hides configs like .env and .git. |
| ls -lh | Same listing, but sizes shown as 4.2K instead of 4200 — for hunting a huge file. |
| cd - | Jumps back to wherever you just were — the undo button for cd. |
| cd ~ | Home, no matter how deep you've wandered. |
| find . -type d | Lists every folder under here — the map before you go searching inside them. |
Files
| Command | What it does |
|---|---|
| cp file.txt backup.txt | Duplicates a file — the original stays untouched. |
| cp -r src/ dest/ | Copies a whole folder tree — plain cp refuses directories outright. |
| mv old.txt new.txt | Renames a file — same command whether you're moving it or just renaming it. |
| rm file.txt | Deletes for good — no trash can to fish it back out of. |
| rm -r folder/ | Deletes a folder and everything inside it — double-check the path first. |
| mkdir -p a/b/c | Creates nested folders in one shot, even if a and b don't exist yet. |
| touch file.txt | Creates an empty file, or just updates its timestamp if it already exists. |
| cat file.txt | Dumps the whole file to the screen — fine for short files, useless for long ones. |
| less file.txt | Opens a file you can scroll and search without it flooding your terminal. |
| head -n 20 file.txt | First 20 lines — the fast way to check what a file even is. |
| tail -f log.txt | Follows a file as it grows — the standard way to watch a log live. |
Searching
| Command | What it does |
|---|---|
| grep -r "TODO" . | Recursively searches file contents — finds a string no matter how deep it's buried. |
| grep -ri "error" log.txt | Case-insensitive search — catches Error, ERROR, and error alike. |
| find . -name "*.env" | Finds files by name pattern anywhere below here, not just the current folder. |
| which node | Prints the exact path of the executable that would run — for chasing down 'command not found' or the wrong version. |
| history | Every command you've typed this session, numbered — !42 reruns line 42. |
| history | grep docker | Searches your command history instead of scrolling back through it. |
Pipes & redirection
| Command | What it does |
|---|---|
| cmd1 | cmd2 | Feeds the output of one command straight into the next — the glue of the shell. |
| cmd > file.txt | Writes output to a file, overwriting whatever was already there. |
| cmd >> file.txt | Appends output to a file instead of overwriting it. |
| cmd > out.log 2>&1 | Sends both normal output and errors into the same file. |
| find . -name "*.tmp" | xargs rm | Turns a list of results into arguments for another command. |
| cmd | tee file.txt | Shows output on screen AND saves it to a file at the same time. |
Processes & help
| Command | What it does |
|---|---|
| ps aux | Lists every running process with its PID — what you need before you can kill anything. |
| kill 1234 | Asks a process to shut down gracefully, by its PID. |
| kill -9 1234 | Forces a stuck process to die immediately — the last resort, not the first. |
| top | A live, updating view of what's eating your CPU and memory right now. |
| Ctrl+C | Stops whatever's running in the foreground — the universal 'get me out of this'. |
| Ctrl+Z | Pauses the foreground job and hands the prompt back — the process is frozen, not stopped. |
| fg | Resumes whatever you just paused with Ctrl+Z, back in the foreground. |
| man ls | Opens the full manual for a command, with every flag it supports. |
| ls --help | A quick flag summary without leaving your prompt — faster than man for a refresher. |
Worth remembering
- →Tab-completion isn't optional — it saves you from typos in paths and surfaces files you forgot existed.
- →rm has no undo — for anything that matters, cp -r it somewhere safe first, or reach for a trash-cli instead.