Not a full manual — just the commands that come up constantly once you're regularly working in a terminal.
Navigation and files
pwd # print working directory
ls -la # list all files, including hidden, with details
cd /path/to/dir # change directory
find . -name "*.log" # find files by name pattern, recursivelySearching inside files
grep -r "TODO" src/ # search recursively for a string
grep -rn "TODO" src/ # same, with line numbers
grep -riE "error|fail" app.log # case-insensitive, extended regexgrep is one of the highest-leverage commands to actually know well — being fast at searching logs and codebases from the terminal saves real time over reaching for a GUI search tool every time.
Process management
ps aux # list all running processes
ps aux | grep node # find a specific process
kill -9 <PID> # force-kill a process by ID
top # live view of resource usage
htop # nicer interactive version of top (often needs installing)Disk and memory
df -h # disk space, human-readable
du -sh * # size of each item in the current directory
free -h # memory usage, human-readablePermissions
chmod +x script.sh # make a file executable
chmod 644 file.txt # rw for owner, r for group/others
chown user:group file # change ownershipPiping and redirection — where the real power is
cat access.log | grep "500" | wc -l # count lines containing "500"
ls -la | sort -k5 -n # sort files by size
command > output.txt # redirect output to a file (overwrite)
command >> output.txt # append instead of overwrite
command 2>&1 # redirect stderr into stdoutThe pipe (|) is what makes the command line genuinely powerful — chaining small, single-purpose tools together to do something none of them do alone.
Networking
curl -I https://example.com # fetch just the response headers
curl -s https://api.example.com/data | jq . # fetch JSON and pretty-print it
ping -c 4 example.com # test connectivity, 4 packets
netstat -tulpn # list listening ports and the processes using themSSH and file transfer
ssh user@host # connect to a remote machine
scp file.txt user@host:/remote/path/ # copy a file to a remote machine
rsync -avz local/ user@host:/remote/ # sync a directory, only transferring changesrsync is worth knowing over scp for anything beyond a single file — it only transfers what's changed, which matters a lot for repeated syncs of large directories.
A habit worth building
man <command> and <command> --help answer most "wait, what were the flags for this again" questions faster than searching the web, and work offline. Building the habit of checking there first, before reaching for a search engine, pays off the more time you spend in a terminal.
Windows developers running these same commands day to day almost always do it through WSL2 rather than a native Linux install — worth setting up first if that's your situation.
Text processing: sed, awk, and cut
Beyond grep for searching, three commands cover most day-to-day text transformation without reaching for a script:
sed 's/foo/bar/g' file.txt # replace all "foo" with "bar"
awk '{print $1, $3}' file.txt # print the 1st and 3rd whitespace-separated columns
cut -d',' -f2 data.csv # extract the 2nd comma-separated fieldawk in particular is worth knowing at least at this basic column-extraction level — a huge amount of ad hoc log and CSV analysis is just "give me columns 1 and 3 from every line," which awk does in one command without opening the file in an editor or writing a script.
Archiving and compression
tar -czvf archive.tar.gz directory/ # create a compressed archive
tar -xzvf archive.tar.gz # extract it
tar -tzvf archive.tar.gz # list contents without extractingThe flag mnemonic worth remembering: c create, x extract, t list, always paired with z (gzip compression), v (verbose output), f (the filename comes next) — tar is one of the few commands where the flags genuinely don't need to be looked up once this pattern is internalized.
Environment variables and shell config
export API_KEY="value" # set for the current shell session and its children
echo $PATH # inspect the current PATH
which node # show exactly which binary a command resolves toexported variables only last for the current shell session unless added to a shell config file (~/.bashrc, ~/.zshrc) — a common point of confusion when a variable set in one terminal tab "disappears" in a new one, which is expected: each new shell session starts fresh unless the variable is defined in a config file that runs on every shell startup.
Job control: running things in the background
long-running-command & # start in the background, return control immediately
jobs # list background jobs in the current shell
fg %1 # bring job 1 back to the foreground
Ctrl+Z # suspend the current foreground job
bg %1 # resume a suspended job in the backgroundWorth distinguishing from nohup: a background job started with & still dies when the terminal session ends, while nohup long-running-command & survives the terminal closing — the right tool specifically for something that needs to keep running after you disconnect.
Common mistakes
- Reaching for
kill -9by default instead of plainkillfirst. SIGKILL gives the process zero chance to close file handles, flush writes, or clean up — fine for a genuinely hung process, unnecessarily destructive for one that would respond to a normal termination request. - Running
rm -rf(especially with a wildcard) without double-checking the current directory and the exact path first — one of the few commands on this list with no undo, and a misplaced space or wrong working directory is the classic way it goes wrong. - Forgetting
-rwhen trying todu/cp/rma directory, or forgetting it's implied differently across commands — the flag conventions aren't perfectly consistent between tools, and assuming they are causes real mistakes. - Piping
grepoutput into moregrep/awk/sedcalls when a single command with the right flags (grep -c,grep -o, extended regex) would do it in one step — not wrong, just worth knowing the shorter path exists.
Related reading
- WSL2 Setup Guide: Running Linux on Windows for Development — shares tags: linux, productivity.
- Understanding File Permissions in Linux (chmod, chown Explained) — shares tags: linux (same category).
- Big O Notation Without the Math Panic — shares tags: productivity.
- Clean Code Principles That Actually Hold Up in Practice — shares tags: productivity.
- Understanding Cloud Cost Optimization Basics — shares tags: productivity.