Reference

CLI Command Cheat Sheet

A searchable rundown of shell commands you actually reach for — git, grep, curl, ssh, docker, find, awk, sed, package managers, archive tools, the lot — with canonical syntax, the flags you use 90% of the time, a couple of examples, the gotcha that bites everyone, and per-row OS badges so you know whether it runs on Linux, macOS, Windows, or in your Termux shell.

How to use: pick a category tab or filter live by typing into the search box (matches across name, description, syntax, flags, and examples). Tap any abbreviated term in a cell to see what it stands for. The command column stays pinned as you scroll horizontally.

12 categories 129 commands Last updated

OS Compatibility Legend

Each row carries one or more badges showing where the command runs. Combine 🛡 root with the OS badges when the command requires elevated privileges.

  • Linux
  • macOS
  • Windows
  • Cross-platform
  • Requires root / sudo
  • Android (Termux)
Shell & CLI Glossary 17 terms

Click any term to see a beginner-friendly explanation. Cross-references inside an explanation open in a stacked modal — Escape closes them one at a time.

Command Description Syntax Flags / Options Examples Gotchas See also OS
ls List directory contents. ls [-l] [-a] [-h] [-S|-t] [-r] [<path>...]
7 flags -l · Long format: permissions, owner, size, mtime. Show all
-l
Long format: permissions, owner, size, mtime.
-a
Include dotfiles (entries starting with '.').
-h
Human-readable sizes (K, M, G) — combine with -l.
-S
Sort by file size, largest first.
-t
Sort by modification time, newest first.
-r
Reverse the sort order.
-R
Recurse into subdirectories.
ls -lahls -lhS /var/log | headls -lt --color=auto

macOS ships BSD ls, which lacks --color=auto (use -G instead) and orders flags differently. Install GNU coreutils via Homebrew (brew install coreutils) to get gls matching Linux behaviour.

cd, tree, stat
🐧🍎⚙️🤖
cd Change the current shell directory. cd [<dir>|-|~]
3 flags - · Switch back to the previous directory ($OLDPWD). Show all
-
Switch back to the previous directory ($OLDPWD).
~
Home directory (also bare 'cd' with no arg).
..
Parent directory.
cd ~/projects/websitecd -cd

cd is a shell builtin, not a binary — it can’t be run via sudo or xargs. Use pushd / popd if you need a directory stack.

pwd, pushd
⚙️
pwd Print the current working directory. pwd [-L|-P]
2 flags
-L
Logical path — follows symlinks (default).
-P
Physical path — resolves symlinks.
pwdpwd -P
cd, realpath
⚙️
mkdir Create one or more directories. mkdir [-p] [-m <mode>] <dir>...
2 flags
-p
Create parent directories as needed; do not error if it exists.
-m <mode>
Set permissions on the new directory (octal, e.g. 700).
mkdir -p src/components/authmkdir -m 700 ~/.ssh
rmdir, chmod
🐧🍎⚙️🤖
rm Remove files and directories. rm [-r] [-f] [-i] <file>...
4 flags -r · Recursive — remove directories and their contents. Show all
-r
Recursive — remove directories and their contents.
-f
Force — never prompt, ignore non-existent files.
-i
Interactive — prompt before each removal.
-v
Verbose — print each file as it's removed.
rm old.logrm -rf node_modulesrm -i *.tmp

rm -rf / is the canonical destructive command. On macOS and modern GNU coreutils, rm refuses / without --no-preserve-root, but a leading variable that resolves to empty (rm -rf "$VAR"/) still nukes / — always quote-test critical paths. There is no undelete.

mv, rmdir, trash
🐧🍎⚙️🤖
mv Move (rename) files and directories. mv [-i] [-n] [-v] <src>... <dst>
3 flags -i · Prompt before overwriting an existing destination. Show all
-i
Prompt before overwriting an existing destination.
-n
Never overwrite — silently skip if dst exists.
-v
Verbose — print each move.
mv old.txt new.txtmv -i src/foo.js src/bar.jsmv *.png images/
cp, rename, rm
🐧🍎⚙️🤖
cp Copy files and directories. cp [-r] [-i] [-p] [-v] <src>... <dst>
5 flags -r · Recursive — copy directories and contents. Show all
-r
Recursive — copy directories and contents.
-i
Prompt before overwriting.
-p
Preserve mode, ownership, and timestamps.
-a
Archive — preserve everything, symlinks too (GNU only).
-v
Verbose — print each copy.
cp config.yml config.yml.bakcp -r src/ dist/cp -a /etc/nginx ~/nginx-backup

BSD cp (macOS) has no -a; use cp -pR or install GNU coreutils. Trailing / on the source means “contents of” — cp -r src/ dst/ copies the contents of src into dst, while cp -r src dst/ copies the src directory itself into dst.

mv, rsync
🐧🍎⚙️🤖
touch Create empty files or update their access / modification time. touch [-c] [-d <date>] [-r <ref>] <file>...
3 flags -c · Do not create the file if it doesn't exist. Show all
-c
Do not create the file if it doesn't exist.
-d <date>
Set the timestamp explicitly (e.g. '2026-01-01 12:00').
-r <ref>
Copy timestamps from another file.
touch placeholder.mdtouch -d '2026-01-01' new.txt
stat, mkdir
🐧🍎⚙️🤖
ln Create hard or symbolic links. ln [-s] [-f] <target> <link_name>
3 flags -s · Symbolic (soft) link — a pointer to a path. Show all
-s
Symbolic (soft) link — a pointer to a path.
-f
Force — remove an existing link before creating the new one.
-v
Print each link as it's created.
ln -s ~/projects/website currentln -sf /opt/node-22/bin/node /usr/local/bin/node

Hard links share the same inode and break if the file system runs out of inodes; you can’t hard-link across file systems or to directories. Symbolic links can point at anything but become broken if the target moves.

readlink, realpath
🐧🍎⚙️🤖
stat Display detailed file metadata (inode, size, perms, timestamps). stat [-c <fmt>|--format=<fmt>] <file>...
2 flags
-c <fmt>
GNU custom format string (%s = size, %y = mtime, %a = octal mode).
-f <fmt>
BSD/macOS custom format string.
stat README.mdstat -c '%n %s %y' *.log

Format strings differ between GNU stat (Linux: -c) and BSD stat (macOS: -f). Cross-platform scripts should detect or fall back to ls -l.

ls, file
🐧🍎⚙️🤖
file Identify a file's type by its content (magic numbers), not its extension. file [-b] [-i] <path>...
2 flags
-b
Brief — omit the filename from output.
-i
Print MIME type instead of human-readable description.
file mystery.binfile -i *.dat
stat
🐧🍎⚙️🤖
tree Show a directory hierarchy as an ASCII tree. tree [-L <depth>] [-a] [-d] [-I <pattern>] [<path>]
4 flags -L <n> · Limit depth to n levels. Show all
-L <n>
Limit depth to n levels.
-a
Show dotfiles.
-d
Directories only.
-I <pat>
Ignore files matching the glob pattern.
tree -L 2tree -I 'node_modules|.git' src

Not installed by default on macOS (brew install tree) or many minimal Linux containers (apt install tree).

ls, find
🐧🍎⚙️🤖
realpath Resolve a path to its absolute, symlink-free canonical form. realpath [-e] [-s] <path>
2 flags
-e
All components must exist (error otherwise).
-s
Strip .. and . but don't resolve symlinks.
realpath ./config.ymlrealpath -s ../../foo

Not available on stock macOS — install via brew install coreutils and use grealpath, or fall back to readlink -f (also macOS-missing) or cd "$(dirname p)" && pwd.

readlink, pwd
🐧⚙️🤖
grep Search text for lines matching a pattern. grep [-i] [-r] [-n] [-E|-F|-P] [-v] <pattern> [<file>...]
11 flags -i · Case-insensitive match. Show all
-i
Case-insensitive match.
-r
Recursive search through directories.
-n
Prefix each match with its line number.
-E
Extended regex (POSIX ERE) — +, ?, |, () without backslashes.
-F
Fixed-string match (no regex). Fastest mode.
-P
Perl-compatible regex (lookaround, \d, etc.). GNU only.
-v
Invert — print lines that do NOT match.
-l
Print only filenames containing a match.
-c
Print only the count of matching lines per file.
-A <n>
Print n lines of trailing context after each match.
-B <n>
Print n lines of leading context before each match.
grep -in "error" server.loggrep -rEn "TODO|FIXME" src/ps aux | grep -v grep | grep nginx

macOS ships BSD grep, which lacks -P and orders flags differently. Install GNU grep via brew install grep for cross-platform ggrep. Patterns starting with - need a -- separator (grep -- -foo file). ripgrep (rg) is faster, respects .gitignore, and is generally preferable for ad-hoc work.

awk, sed, find, ripgrep
🐧🍎⚙️🤖
find Walk a directory tree and act on files matching tests. find <path>... [tests] [actions]
8 flags -name <glob> · Match filename by glob (case-sensitive). Show all
-name <glob>
Match filename by glob (case-sensitive).
-iname <glob>
Case-insensitive filename match.
-type f|d|l
Restrict to files (f), directories (d), or symlinks (l).
-mtime <n>
Modified n*24 hours ago (+n = older, -n = newer).
-size <n>[ckMG]
Size match (+ = larger, - = smaller; suffix sets unit).
-delete
Delete matching files (use only after dry-running with -print).
-exec <cmd> {} \;
Run command per file ({} is replaced with the path).
-exec <cmd> {} +
Run command once with all paths batched as args (faster).
find . -name '*.log' -mtime +30 -deletefind src -type f -name '*.tsx' -exec grep -l TODO {} +find /var/log -type f -size +100M

-print is the default action — drop it for clarity, add it back when piping into xargs with weird filenames (use -print0 + xargs -0 to handle spaces). BSD find (macOS) and GNU find have minor flag differences (-printf is GNU-only).

xargs, grep, fd
🐧🍎⚙️🤖
awk Pattern-action language for column-oriented text processing. awk [-F <sep>] '<pattern> { <action> }' [<file>...]
3 flags -F <sep> · Input field separator (default: whitespace runs). Show all
-F <sep>
Input field separator (default: whitespace runs).
-v <var>=<val>
Set an awk variable before execution.
-f <script>
Read the awk program from a file.
awk '{print $2, $5}' access.logawk -F, '$3 > 100 {print}' data.csvawk 'NR>1 {sum+=$2} END {print sum}' nums.txt

NR is the line number, NF the field count; $0 is the whole line, $1..$NF the fields. Built-in to every Unix; for anything more elaborate, reach for Python or jq (for JSON).

sed, cut, grep
🐧🍎⚙️🤖
sed Stream editor — apply scripted edits to a stream of text. sed [-i[<ext>]] [-E] '<script>' [<file>...]
4 flags -i · Edit files in place (GNU). BSD/macOS requires -... Show all
-i
Edit files in place (GNU). BSD/macOS requires -i ''.
-E
Extended regex (so + ? () work without backslashes).
-n
Suppress default output (use with /pat/p to print only matches).
-e <script>
Add another script; repeat for multiple.
sed 's/foo/bar/g' input.txtsed -i 's/localhost/127.0.0.1/g' config.ymlsed -n '10,20p' file.txt

sed -i means “in-place” on GNU but BSD/macOS requires a backup-extension arg (sed -i '' 's/…'). The portable form is sed -i.bak 's/…' which works on both and leaves a .bak behind. Don’t mix delimiters inside the script: use s|/path|/new|g when the pattern contains slashes.

awk, tr, grep
🐧🍎⚙️🤖
cut Extract specific bytes, characters, or fields from each line. cut [-d <delim>] -f <fields> [<file>...]
3 flags -d <delim> · Field delimiter (default: tab). Show all
-d <delim>
Field delimiter (default: tab).
-f <list>
Field list (1,3 or 2-5 or 3-).
-c <list>
Character positions instead of fields.
cut -d: -f1 /etc/passwdcut -f2-4 data.tsv
awk, paste
🐧🍎⚙️🤖
sort Sort lines of text. sort [-n] [-r] [-u] [-k <field>] [-t <sep>] [<file>...]
6 flags -n · Numeric sort (so 10 follows 9, not 1). Show all
-n
Numeric sort (so 10 follows 9, not 1).
-r
Reverse order.
-u
Output unique lines only (like uniq, no need to pre-sort).
-k <field>
Sort on field N (1-indexed).
-t <sep>
Field separator (default: whitespace).
-h
Human-readable numeric sort (handles 1K, 2M, 3G).
sort -u names.txtsort -t, -k3 -n data.csvdu -sh */ | sort -h
uniq, shuf
🐧🍎⚙️🤖
uniq Filter adjacent duplicate lines. uniq [-c] [-d] [-u] [<file>]
3 flags -c · Prefix each line with its occurrence count. Show all
-c
Prefix each line with its occurrence count.
-d
Only print lines that appear more than once.
-u
Only print lines that appear exactly once.
sort access.log | uniq -c | sort -rn | headsort emails.txt | uniq -d

uniq only collapses adjacent duplicates — pipe sort in first, or use sort -u for a one-step equivalent.

sort
🐧🍎⚙️🤖
head Print the first N lines (or bytes) of a stream. head [-n <count>|-c <bytes>] [<file>...]
2 flags
-n <n>
First n lines (default: 10). Negative means all but last n.
-c <n>
First n bytes.
head -n 20 server.loghead -c 1024 big.bin | xxd
tail, less
🐧🍎⚙️🤖
tail Print the last N lines, optionally following a growing file. tail [-n <count>] [-f] [<file>...]
3 flags -n <n> · Last n lines (default: 10). +n starts at line n. Show all
-n <n>
Last n lines (default: 10). +n starts at line n.
-f
Follow — keep printing as the file grows.
-F
Follow even across log rotation (re-open by name).
tail -n 100 access.logtail -F /var/log/nginx/error.log
head, less
🐧🍎⚙️🤖
less Page through text interactively (forward and backward). less [+<line>] [-N] [-S] [-R] [<file>]
4 flags +<line> · Start at the given line number. Show all
+<line>
Start at the given line number.
-N
Show line numbers.
-S
Chop long lines instead of wrapping.
-R
Pass ANSI colour codes through.
less +F /var/log/sysloggit log --oneline | less -S

Inside less: /pattern searches forward, ?pattern searches backward, n/N jumps next/prev, g/G go to top/bottom, q quits. +F tails the file like tail -f until Ctrl+C drops you into normal less mode.

more, tail, head
🐧🍎⚙️🤖
cat Concatenate files and print to stdout. cat [-n] [-A] [<file>...]
2 flags
-n
Number every output line.
-A
Show all non-printable chars ($ for newlines, ^I for tabs).
cat file1 file2 > combined.txtcat -n script.sh

“Useless use of cat” — cat file | grep x is just grep x file. Pipelines work better when you don’t detach the input from its source.

tac, head, tail
🐧🍎⚙️🤖
tee Read stdin, write to stdout AND to one or more files. tee [-a] <file>...
1 flag
-a
Append to files instead of overwriting.
make 2>&1 | tee build.logecho nameserver 1.1.1.1 | sudo tee -a /etc/resolv.conf

The echo … | sudo tee -a pattern is how you write to a root-only file when you can’t run sudo on a redirect (because >> is interpreted by your unprivileged shell, not the sudo’d process).

cat, xargs
🐧🍎⚙️🤖
xargs Build and execute commands from stdin. xargs [-0] [-n <max>] [-I <repl>] [-P <jobs>] <cmd>
4 flags -0 · Input is null-separated (pair with find -print0). Show all
-0
Input is null-separated (pair with find -print0).
-n <n>
Max args per command invocation.
-I <repl>
Replace in cmd with each input item.
-P <n>
Run up to n commands in parallel.
find . -name '*.tmp' -print0 | xargs -0 rmcat hosts.txt | xargs -I {} ssh {} uptimels *.png | xargs -P 4 -n 1 optipng

Without -0, filenames with spaces or newlines break. Always pair find -print0 with xargs -0. -I {} implies -n 1.

find, parallel
🐧🍎⚙️🤖
jq Filter, transform, and query JSON from the command line. jq [-r] [-c] '<filter>' [<file>]
4 flags -r · Raw output — strings without surrounding quotes. Show all
-r
Raw output — strings without surrounding quotes.
-c
Compact (one JSON value per line).
-s
Slurp — read all input into one big array.
-e
Exit non-zero if the filter produces no/false output.
curl -s api.example/v1/users | jq '.[] | .name'jq -r '.items[] | [.id, .name] | @csv' data.jsonjq '.users |= map(. + {active: true})' in.json

Not installed by default — apt install jq / brew install jq. For YAML use yq (the Mike Farah Go reimplementation); they share most of the syntax.

awk, yq
🐧🍎⚙️🤖
wc Count lines, words, characters, or bytes. wc [-l] [-w] [-c] [-m] [<file>...]
4 flags -l · Lines only. Show all
-l
Lines only.
-w
Words only.
-c
Bytes only.
-m
Characters (matters for multi-byte UTF-8).
wc -l *.pyfind . -name '*.tsx' | wc -l
awk
🐧🍎⚙️🤖
tr Translate or delete characters from stdin. tr [-d] [-s] [-c] '<set1>' ['<set2>']
3 flags -d · Delete characters in set1. Show all
-d
Delete characters in set1.
-s
Squeeze repeated chars in set1 to a single occurrence.
-c
Complement set1 (act on chars NOT in it).
echo 'Hello' | tr 'a-z' 'A-Z'tr -d '\r' < dos.txt > unix.txttr -s ' ' < spaced.txt
sed, awk
🐧🍎⚙️🤖
ps Snapshot the current process list. ps [aux | -ef] [-o <fmt>]
3 flags aux · BSD style: all users, including no-controlling-... Show all
aux
BSD style: all users, including no-controlling-terminal procs.
-ef
POSIX style: full format, every process.
-o <fmt>
Custom output columns (e.g. pid,user,%cpu,%mem,cmd).
ps aux | grep nginxps -eo pid,user,%cpu,%mem,cmd --sort=-%mem | head

ps aux and ps -ef are nearly equivalent but use different flag syntax (BSD vs POSIX). On modern Linux either works; on minimal busybox boxes (and some Android setups) only one is available.

top, pgrep, htop
🐧🍎⚙️🤖
top Live, sortable view of running processes. top [-d <delay>] [-n <iters>] [-o <field>] [-u <user>]
4 flags -d <s> · Refresh delay in seconds (default: 3 on Linux, ... Show all
-d <s>
Refresh delay in seconds (default: 3 on Linux, 1 on macOS).
-n <n>
Run for n iterations then exit (good for scripts).
-o <field>
Sort by field (cpu, mem, time).
-u <user>
Show only this user's processes.
top -o cputop -n 1 -b > snapshot.txt

Linux top and macOS top are different binaries with different keybindings. Inside Linux top: P sort by CPU, M by memory, k kill a PID, q quit.

htop, ps, iotop
🐧🍎⚙️🤖
htop Interactive process viewer with colour, mouse support, and tree mode. htop [-d <ds>] [-u <user>] [-p <pid>...]
3 flags -u <user> · Show only this user's processes. Show all
-u <user>
Show only this user's processes.
-p <pid,...>
Show only the listed PIDs.
-t
Start in tree view.
htophtop -u www-data -t

Not installed by default — apt install htop / brew install htop / pkg install htop in Termux. Inside htop: F5 tree, F6 sort, F9 kill, F10 quit.

top, btop
🐧🍎⚙️🤖
kill Send a signal to one or more processes (default: SIGTERM). kill [-<signal>|-l] <pid>...
4 flags -9 / -KILL · SIGKILL — unblockable, kernel kills the process. Show all
-9 / -KILL
SIGKILL — unblockable, kernel kills the process.
-15 / -TERM
SIGTERM — graceful shutdown (default).
-1 / -HUP
SIGHUP — many daemons reload config on this.
-l
List all signal names.
kill 12345kill -HUP $(pgrep nginx)kill -9 1234

Reach for -15 first — -9 bypasses cleanup and can leave locked files, half-written data, or zombie children. A process that ignores -15 for >5s is the only candidate for -9.

pkill, killall, pgrep
🐧🍎⚙️🤖
pkill Kill processes by name pattern instead of PID. pkill [-<signal>] [-f] [-u <user>] <pattern>
3 flags -f · Match against the full command line, not just t... Show all
-f
Match against the full command line, not just the process name.
-u <user>
Only kill processes owned by this user.
-<signal>
Which signal to send (default: TERM).
pkill nginxpkill -f 'python my-script.py'
kill, pgrep, killall
🐧🍎⚙️🤖
pgrep List PIDs of processes matching a name pattern. pgrep [-f] [-u <user>] [-a] <pattern>
3 flags -f · Match the full command line. Show all
-f
Match the full command line.
-a
Print the command line alongside the PID.
-u <user>
Restrict to one user.
pgrep -a nginxpgrep -fu $USER node
pkill, ps
🐧🍎⚙️🤖
jobs List the current shell's background and stopped jobs. jobs [-l] [-p]
2 flags
-l
Include PIDs in the output.
-p
Print PIDs only.
jobsjobs -l

Jobs are shell-local — they disappear when the shell exits unless you use nohup or disown. Use fg %1 to foreground job 1, bg %1 to resume it in the background.

bg, fg, nohup, disown
⚙️
nohup Run a command immune to hangups (so it survives shell exit). nohup <cmd> [args...] [&]
nohup ./long-build.sh &nohup python serve.py > server.log 2>&1 &

Output goes to nohup.out in the current directory unless you redirect explicitly. For something more durable, use systemd service units (Linux), launchd (macOS), or a terminal multiplexer like tmux.

disown, tmux, screen
🐧🍎⚙️🤖
lsof List open files (including network sockets) and their owning processes. lsof [-i [<host>:<port>]] [-p <pid>] [-u <user>]
4 flags -i · Internet sockets — append : or @host. Show all
-i
Internet sockets — append : or @host.
-p <pid>
Files opened by a specific PID.
-u <user>
Files opened by a specific user.
+D <dir>
All open files under a directory.
lsof -i :3000sudo lsof -p $(pgrep nginx)lsof +D /var/log

Almost always needs sudo to see other users’ files / sockets. On Linux, ss -ltnp is faster for “what’s listening on which port”.

ss, netstat, fuser
🐧🍎⚙️
time Run a command and report how long it took. time <cmd> [args...]
time make buildtime curl -s https://example.com > /dev/null

time is both a shell builtin and a binary (/usr/bin/time). The builtin (which most shells default to) shows real/user/sys; the binary supports -v for memory and I/O stats (/usr/bin/time -v ... on Linux).

hyperfine
⚙️
curl Transfer data to / from URLs (HTTP, HTTPS, FTP, SFTP, …). curl [-X <method>] [-H "<header>"] [-d <data>] [-o <file>] [-L] [-sS] <url>
11 flags -X <method> · HTTP method (GET default; POST, PUT, DELETE, PA... Show all
-X <method>
HTTP method (GET default; POST, PUT, DELETE, PATCH…).
-H "<header>"
Add a request header; repeat for multiple.
-d <data>
Request body (also implies POST if -X is not set).
--data-binary @<file>
Send the contents of a file as the body, byte-for-byte.
-o <file>
Write response body to a file instead of stdout.
-O
Save as the URL's basename.
-L
Follow 3xx redirects.
-sS
Silent (-s) but show errors (-S). Common in scripts.
-I
HEAD request — fetch headers only.
-u <user>:<pass>
HTTP basic auth.
-v
Verbose — print full request and response headers.
curl -sSL https://example.com/install.sh | shcurl -X POST -H "Content-Type: application/json" -d '{"k":1}' https://api.example/v1/datacurl -o output.bin -L https://files.example/dl/123

curl | sh executes arbitrary network code — only do this for sources you trust. Default macOS curl lacks brotli/zstd support — install via Homebrew for full features. Use --fail in scripts so 4xx/5xx responses produce a non-zero exit code.

wget, httpie, rsync
⚙️
wget Non-interactive network downloader. wget [-O <file>] [-c] [-r] [-N] <url>
5 flags -O <file> · Output filename (- for stdout). Show all
-O <file>
Output filename (- for stdout).
-c
Continue a partially downloaded file.
-r
Recursive — mirror a site.
-N
Only download if newer than the local copy.
-q
Quiet — no output.
wget https://example.com/big.isowget -c https://files.example/huge.tar.gzwget -r -N -np https://docs.example.com/manual/

Not installed on macOS by default — brew install wget. curl covers most of the same use cases and is preinstalled everywhere.

curl, aria2c
🐧⚙️🤖
ping Send ICMP echo requests to a host and report round-trip time. ping [-c <count>] [-i <interval>] [-W <timeout>] <host>
4 flags -c <n> · Stop after n requests. Show all
-c <n>
Stop after n requests.
-i <s>
Wait s seconds between requests (default 1).
-W <s>
Per-reply timeout in seconds.
-4 / -6
Force IPv4 or IPv6.
ping -c 4 1.1.1.1ping -i 0.2 example.com

Some networks block ICMP — “ping fails” doesn’t always mean the host is down. Sub-second -i values usually require root.

traceroute, mtr
🐧🍎⚙️🤖
traceroute Show the network path (hop by hop) to a host. traceroute [-n] [-T] [-w <s>] <host>
4 flags -n · Numeric only — don't resolve hostnames (faster). Show all
-n
Numeric only — don't resolve hostnames (faster).
-T
Use TCP SYN instead of UDP (often gets past firewalls).
-I
Use ICMP echo (Linux: needs root).
-w <s>
Wait s seconds for each reply.
traceroute -n example.comsudo traceroute -T -p 443 example.com
mtr, ping
🐧🍎⚙️
mtr Combined traceroute + ping with a live rolling display. mtr [-r] [-c <count>] [-w] <host>
3 flags -r · Report mode — run N cycles then print and exit. Show all
-r
Report mode — run N cycles then print and exit.
-c <n>
Number of cycles.
-w
Wide report (no truncated hostnames).
mtr -rwc 20 example.com
traceroute, ping
🐧🍎⚙️
dig Detailed DNS lookups (the canonical DNS debugger). dig [@<server>] <name> [<type>] [+short]
4 flags @<server> · Use this DNS server instead of the system resol... Show all
@<server>
Use this DNS server instead of the system resolver.
<type>
Record type — A, AAAA, MX, TXT, NS, CNAME, SOA, ANY.
+short
Compact output — just the answer.
+trace
Trace the query from the roots downward.
dig example.comdig @1.1.1.1 example.com MX +shortdig +trace example.com
host, nslookup
🐧🍎⚙️
host Simpler DNS lookup utility — terse output by default. host [-t <type>] <name> [<server>]
2 flags
-t <type>
Record type (A, MX, TXT, …).
-a
All record types.
host example.comhost -t MX example.com
dig, nslookup
🐧🍎⚙️
nslookup Older interactive DNS query tool (still useful on Windows). nslookup <name> [<server>]
nslookup example.comnslookup example.com 8.8.8.8

dig is more powerful and has better scripting support; reach for nslookup on Windows where dig isn’t bundled.

dig, host
🐧🍎🪟⚙️
ss Inspect sockets — listening ports, established connections, stats. ss [-l] [-t] [-u] [-n] [-p] [-a]
6 flags -l · Listening sockets only. Show all
-l
Listening sockets only.
-t
TCP.
-u
UDP.
-n
Numeric — don't resolve hosts or services.
-p
Show the owning process (needs root for others).
-a
All sockets (default: not listening).
ss -ltnpsudo ss -tunap | grep 443

ss replaced netstat on modern Linux — faster and reads /proc/net directly. macOS uses netstat + lsof -i instead.

netstat, lsof
🐧
netstat List network connections, routing tables, interface stats. netstat [-l] [-t] [-u] [-n] [-p] [-r]
5 flags -l · Listening sockets. Show all
-l
Listening sockets.
-t / -u
TCP / UDP.
-n
Numeric.
-p
Show owning process (Linux; not BSD/macOS).
-r
Routing table.
netstat -ltnnetstat -rn

Deprecated on modern Linux in favour of ss (faster same data). Still standard on macOS, BSD, and Windows.

ss, lsof, route
🐧🍎🪟⚙️
nmap Port scanner and network discovery tool. nmap [-sS|-sT|-sU] [-p <ports>] [-A] [-Pn] <target>
6 flags -sS · TCP SYN (stealth) scan — requires root. Show all
-sS
TCP SYN (stealth) scan — requires root.
-sT
TCP connect scan — no root needed but more visible.
-sU
UDP scan.
-p <ports>
Ports list (22,80,443 or 1-1024).
-A
Aggressive: OS detect, version, scripts, traceroute.
-Pn
Skip host discovery — treat all hosts as up.
nmap -sT -p 22,80,443 example.comsudo nmap -A 192.168.1.0/24

Only scan networks you own or have written permission to scan. Aggressive scans are noisy and may trigger IDS alerts.

ss, masscan
🐧🍎🪟⚙️🛡
ip Show / manipulate routing, devices, addresses, tunnels (modern Linux). ip [<object>] [<command>] [<args>]
4 flags ip addr · Show IP addresses on all interfaces. Show all
ip addr
Show IP addresses on all interfaces.
ip link
Show / change interface link state.
ip route
Show / change the routing table.
ip -br a
Brief one-line-per-interface summary.
ip addr showip -br asudo ip route add 10.0.0.0/8 via 192.168.1.1

Replaced the older ifconfig / route / arp trio. Not available on macOS — use ifconfig + route + netstat -rn there.

ifconfig, ss
🐧🛡
ifconfig Show / configure network interfaces (legacy Linux, default macOS). ifconfig [<iface>] [up|down]
ifconfigsudo ifconfig en0 down

Deprecated on modern Linux (use ip). Still default on macOS and BSD.

ip
🐧🍎⚙️
ssh Open an authenticated, encrypted shell on a remote host. ssh [-p <port>] [-i <key>] [-L|-R <fwd>] [<user>@]<host> [<cmd>]
10 flags -p <port> · Use a non-default port (default 22). Show all
-p <port>
Use a non-default port (default 22).
-i <keyfile>
Identity file — private key to use for auth.
-L <lport>:<rhost>:<rport>
Local port forward — bind local port to a remote-side address.
-R <rport>:<lhost>:<lport>
Remote port forward — open a port on the remote that tunnels back to you.
-D <port>
SOCKS proxy on the local port.
-J <user@jump>
Hop via a jump host.
-N
Don't execute a remote command — useful with -L / -R / -D.
-f
Background after auth — good for tunnels.
-A
Forward your ssh-agent (be careful on untrusted hosts).
-v
Verbose; -vv / -vvv for more detail (debugging auth).
ssh user@example.comssh -i ~/.ssh/id_ed25519 -p 2222 deploy@app.examplessh -L 5432:localhost:5432 db.example -Nssh -J bastion@gateway.example app@internal-host

Config goes in ~/.ssh/config — set HostName, User, Port, IdentityFile per host and never type those flags again. StrictHostKeyChecking accept-new is the sane default (warns on changed keys but accepts first contact). Agent forwarding (-A) gives the remote sudo over your local keys — don’t enable it on shared boxes.

scp, rsync, ssh-keygen, ssh-copy-id
⚙️
scp Copy files over SSH. scp [-r] [-P <port>] [-i <key>] <src>... [<user>@]<host>:<dst>
5 flags -r · Recursive — copy directories. Show all
-r
Recursive — copy directories.
-P <port>
Remote port (note: capital P, unlike ssh's -p).
-i <key>
Identity file.
-p
Preserve timestamps and mode.
-C
Compress in transit.
scp deploy.tar.gz user@server.example:/tmp/scp -r dist/ user@server.example:/var/www/scp user@server:/etc/nginx/nginx.conf ./

OpenSSH 9+ switched scp’s wire protocol from RCP to SFTP — behaves similarly but rejects some old quoting tricks. For anything beyond trivial copies, prefer rsync (resumes, delta transfer, much faster on retries).

rsync, sftp, ssh
⚙️
rsync Fast incremental file sync (local or over SSH) with delta transfer. rsync [-a] [-v] [--delete] [-z] [-P] <src>/ <dst>/
8 flags -a · Archive — recursive + symlinks + perms + times ... Show all
-a
Archive — recursive + symlinks + perms + times + group + owner.
-v
Verbose.
-z
Compress in transit.
--delete
Delete files on dst that aren't in src (mirror).
-n / --dry-run
Preview what would change without doing it.
-P
Progress bar + partial-resume on interrupted transfers.
-e "ssh -p <port>"
Use a custom SSH command (e.g. non-default port).
--exclude=<pat>
Skip paths matching the pattern (repeat for multiple).
rsync -avP src/ dst/rsync -avz --delete ./dist/ user@server:/var/www/rsync -avn --exclude='node_modules' ./ backup/

Trailing / matters: src/ means “contents of src”, src means “the src dir itself”. Always dry-run --delete first. -a is shorthand for -rlptgoD; drop -a and explicitly pick flags if you don’t want owners/groups preserved.

scp, tar, cp
⚙️
ssh-keygen Generate, inspect, and manage SSH keypairs. ssh-keygen [-t <algo>] [-b <bits>] [-f <path>] [-C <comment>]
7 flags -t ed25519 · Modern, fast, secure default. Pick this. Show all
-t ed25519
Modern, fast, secure default. Pick this.
-t rsa -b 4096
RSA fallback for old servers that don't support ed25519.
-f <path>
Output keypair to this path (and path.pub).
-C <comment>
Comment appended to the public key — usually your email.
-N ""
Empty passphrase (only for unattended use; otherwise omit).
-y -f <key>
Print the public key for an existing private key.
-l -f <key>
Print the fingerprint of a key.
ssh-keygen -t ed25519 -C "you@example.com"ssh-keygen -lf ~/.ssh/id_ed25519.pubssh-keygen -y -f ~/.ssh/id_ed25519

Default output path is ~/.ssh/id_ed25519 — answer the prompts if you want a different location. Use a passphrase for anything that touches production; pair with ssh-add so you only enter it once per session.

ssh, ssh-copy-id, ssh-add
⚙️
ssh-copy-id Install your public key into a remote user's authorized_keys. ssh-copy-id [-i <pubkey>] [-p <port>] [<user>@]<host>
3 flags -i <pubkey> · Which public key to install. Show all
-i <pubkey>
Which public key to install.
-p <port>
Non-default SSH port.
-f
Force — skip the test-key-already-present check.
ssh-copy-id user@server.examplessh-copy-id -i ~/.ssh/deploy.pub -p 2222 deploy@app.example

Not bundled with Windows OpenSSH — workaround: cat ~/.ssh/id_ed25519.pub | ssh user@host 'cat >> ~/.ssh/authorized_keys'.

ssh, ssh-keygen
🐧🍎⚙️
sftp Interactive file transfer over SSH (FTP-like commands). sftp [-P <port>] [-i <key>] [<user>@]<host>
sftp user@server.examplesftp -i ~/.ssh/id_ed25519 deploy@app.example

Once connected: ls, cd, get, put, mget, mput, bye. sshfs (FUSE) mounts a remote dir as a local filesystem if you’d rather use regular file tools.

scp, rsync, sshfs
⚙️
mosh Mobile shell — SSH-like but survives roaming, sleep, and packet loss. mosh [<user>@]<host>
mosh user@laggy-server.example

Uses UDP on ports 60000–61000 — open those if your network blocks them. Needs mosh installed on both ends (server-side acts as a relay). For SSH-only environments stick with ssh + tmux.

ssh, tmux
🐧🍎⚙️🤖
git clone Copy a remote repository to your machine. git clone [--depth <n>] [-b <branch>] <url> [<dir>]
4 flags --depth <n> · Shallow clone — only the most recent n commits.... Show all
--depth <n>
Shallow clone — only the most recent n commits. Smaller, faster.
-b <branch>
Clone a specific branch (instead of the default).
--recurse-submodules
Initialise and clone submodules too.
--single-branch
Only fetch the named branch, not all branches.
git clone https://github.com/user/repo.gitgit clone --depth 1 -b main git@github.com:user/repo.gitgit clone --recurse-submodules https://github.com/user/repo.git
git init, git remote
⚙️
git status Show working-tree and staging-area changes. git status [-s] [-b] [--untracked-files=<mode>]
3 flags -s · Short format — two-letter status codes. Show all
-s
Short format — two-letter status codes.
-b
Show current branch + tracking info even in short mode.
-uno / --untracked-files=no
Hide untracked files (faster on big trees).
git statusgit status -sb
git diff, git log
⚙️
git add Stage changes for the next commit. git add [-A|-u|-p] [<pathspec>...]
4 flags -A · Stage everything — new, modified, deleted. Show all
-A
Stage everything — new, modified, deleted.
-u
Stage modified and deleted but NOT new files.
-p
Interactive — pick hunks to stage one by one.
-n / --dry-run
Show what would be added without staging.
git add src/main.tsgit add -Agit add -p

git add . stages everything below the current directory; git add -A stages the entire working tree. Big difference if you’re inside a subfolder. Use -p for surgical commits when one set of edits should be split across multiple commits.

git restore, git reset, git commit
⚙️
git commit Record staged changes as a new commit. git commit [-m "<msg>"] [-a] [--amend] [--no-edit]
5 flags -m "<msg>" · Inline commit message; skips $EDITOR. Show all
-m "<msg>"
Inline commit message; skips $EDITOR.
-a
Stage all tracked, modified files before committing.
--amend
Replace the previous commit. Rewrites history.
--no-edit
Used with --amend to keep the previous message verbatim.
-s / --signoff
Append a Signed-off-by trailer.
git commit -m "fix: trim whitespace in README"git commit -am "quick fix"git commit --amend --no-edit

Never --amend a commit that’s already pushed to a shared branch without coordinating a force-push. -a stages already-tracked files only — new files still need git add first.

git add, git push, git reset, git log
⚙️
git push Upload local commits to a remote branch. git push [-u] [--force-with-lease] [<remote>] [<branch>]
5 flags -u / --set-upstream · Set tracking — first push of a new branch. Show all
-u / --set-upstream
Set tracking — first push of a new branch.
--force
Overwrite remote history. Dangerous on shared branches.
--force-with-lease
Safer force — refuses if someone else pushed since you fetched.
--tags
Push tags too.
--dry-run
Show what would be pushed.
git pushgit push -u origin feature/new-thinggit push --force-with-lease

Default --force can wipe a teammate’s pushed work. Use --force-with-lease — it refuses to push if the remote moved on after your last fetch. Even safer: --force-with-lease=<branch>:<sha> pinning the exact SHA you expect to be overwriting.

git pull, git fetch
⚙️
git pull Fetch from remote and merge / rebase into the current branch. git pull [--rebase] [--ff-only] [<remote>] [<branch>]
3 flags --rebase · Rebase local commits on top of fetched ones (cl... Show all
--rebase
Rebase local commits on top of fetched ones (cleaner history).
--ff-only
Only fast-forward; abort if a merge would be needed.
--no-ff
Always create a merge commit.
git pullgit pull --rebasegit pull --ff-only

Set git config --global pull.rebase true (or pull.ff only) once and you’ll never accidentally create a junky “Merge branch ‘main’ of …” commit again.

git fetch, git merge, git rebase
⚙️
git fetch Download remote commits without merging. git fetch [--all] [--prune] [<remote>] [<refspec>]
3 flags --all · Fetch from every configured remote. Show all
--all
Fetch from every configured remote.
--prune
Remove local refs to branches that no longer exist on the remote.
--tags
Fetch tags too.
git fetchgit fetch --all --prune
git pull, git remote
⚙️
git switch Change branches (the modern replacement for `git checkout` for branches). git switch [-c|-C] [-t <upstream>] <branch>
4 flags -c <branch> · Create and switch to a new branch. Show all
-c <branch>
Create and switch to a new branch.
-C <branch>
Create or reset; force-overwrite if it exists.
-
Switch to the previous branch (like cd -).
--detach
Detach HEAD at a commit instead of moving a branch.
git switch maingit switch -c feature/new-thinggit switch -
git restore, git checkout, git branch
⚙️
git restore Restore files in working tree or staging area (replaces `git checkout -- file`). git restore [--staged] [--source=<commit>] <pathspec>...
3 flags --staged · Unstage — remove from index but keep working-tr... Show all
--staged
Unstage — remove from index but keep working-tree changes.
--source=<ref>
Restore from a specific commit/branch.
-W -S
Restore both working tree (-W) and staged version (-S).
git restore src/foo.tsgit restore --staged src/foo.tsgit restore --source=HEAD~3 README.md
git switch, git reset, git checkout
⚙️
git branch List, create, delete, or rename branches. git branch [-a] [-d|-D <name>] [-m <new>] [<name> [<base>]]
5 flags -a · List local + remote-tracking branches. Show all
-a
List local + remote-tracking branches.
-v / -vv
Show last commit / upstream info.
-d <name>
Delete a merged branch.
-D <name>
Force-delete (even if unmerged).
-m <new>
Rename the current branch.
git branch -agit branch -d old-featuregit branch -m new-name
git switch, git merge
⚙️
git merge Merge another branch into the current one. git merge [--no-ff] [--squash] [--abort] <branch>
4 flags --no-ff · Always create a merge commit, even for fast-for... Show all
--no-ff
Always create a merge commit, even for fast-forwardable cases.
--ff-only
Only allow fast-forward; abort otherwise.
--squash
Squash the merged commits into a single commit (don't auto-commit).
--abort
Bail out of a conflicted merge and reset.
git merge feature/new-thinggit merge --no-ff feature/big-changegit merge --abort
git rebase, git pull
⚙️
git rebase Replay commits onto a different base — rewrites history. git rebase [-i] [--onto <newbase>] [--continue|--abort] <upstream>
5 flags -i · Interactive — pick / squash / reword / drop / r... Show all
-i
Interactive — pick / squash / reword / drop / reorder commits.
--onto <ref>
Reparent onto a specific commit (advanced).
--continue
Resume after resolving a conflict.
--abort
Bail out and reset to the pre-rebase state.
--autosquash
Auto-apply fixup!/squash! commits during interactive rebase.
git rebase maingit rebase -i HEAD~5git rebase --abort

Never rebase commits that have been pushed to a shared branch. Rebasing rewrites SHAs, so anyone with the old SHAs will be on a diverged history.

git merge, git cherry-pick
⚙️
git stash Temporarily shelve working-tree changes. git stash [push -m "<msg>"|pop|list|drop|apply]
6 flags push -m "<msg>" · Save current changes with a label. Show all
push -m "<msg>"
Save current changes with a label.
-u
Include untracked files too.
pop
Apply the top stash and drop it from the list.
apply
Apply without dropping.
list
Show all stashes.
drop stash@{<n>}
Delete a specific stash entry.
git stash push -m "wip: testing thing"git stash popgit stash list

Stashes are local-only — they never push or sync. Don’t treat the stash as long-term storage; commit to a wip branch if you’ll be gone for more than a day.

git commit, git restore
⚙️
git log Show commit history. git log [--oneline] [--graph] [-<n>] [--author=<who>] [<path>...]
7 flags --oneline · One commit per line — SHA + subject. Show all
--oneline
One commit per line — SHA + subject.
--graph
ASCII branch/merge graph.
-<n>
Last n commits.
--author=<who>
Filter by author.
--since=<when>
Commits newer than e.g. '2 weeks ago'.
-p
Show diffs alongside each commit.
--stat
Show per-file change counts.
git log --oneline --graph --all -20git log -p src/main.tsgit log --since='1 week ago' --author=me
git show, git diff, git blame
⚙️
git diff Show changes between commits, branches, working tree, or staging. git diff [--staged] [<commit>[..<commit>]] [-- <path>...]
4 flags --staged / --cached · Diff staged changes vs HEAD. Show all
--staged / --cached
Diff staged changes vs HEAD.
--stat
Summary of changes per file.
--name-only
Just the changed filenames.
-w
Ignore whitespace changes.
git diffgit diff --stagedgit diff main..feature/new-thing -- src/
git log, git show
⚙️
git reset Move HEAD (and optionally the index / working tree) to a different commit. git reset [--soft|--mixed|--hard] [<commit>]
3 flags --soft · Move HEAD only. Index and working tree untouched. Show all
--soft
Move HEAD only. Index and working tree untouched.
--mixed
Move HEAD and reset index. Working tree untouched (default).
--hard
Move HEAD and reset both index and working tree. DESTRUCTIVE.
git reset HEAD~1git reset --soft HEAD~3git reset --hard origin/main

--hard discards uncommitted changes silently — no undo. Use git reflog to recover the previous HEAD if you reset by mistake.

git restore, git revert, git reflog
⚙️
git remote Manage the set of configured remote repositories. git remote [-v | add <name> <url> | set-url <name> <url> | remove <name>]
4 flags -v · Verbose list — show URLs. Show all
-v
Verbose list — show URLs.
add <name> <url>
Add a new remote.
set-url <name> <url>
Change an existing remote's URL.
rename <old> <new>
Rename a remote.
git remote -vgit remote add upstream https://github.com/owner/repo.gitgit remote set-url origin git@github.com:user/repo.git
git fetch, git push
⚙️
git tag Create, list, or delete lightweight / annotated tags. git tag [-a <name> -m "<msg>"] [-d <name>] [-l <glob>]
4 flags -a <name> · Annotated tag (carries metadata + message). Show all
-a <name>
Annotated tag (carries metadata + message).
-m "<msg>"
Annotation message (required with -a).
-d <name>
Delete a local tag.
-l <glob>
List tags matching a glob.
git tag -a v1.0.0 -m "first release"git push --tagsgit tag -d v1.0.0-rc1
git push, git describe
⚙️
apt Debian/Ubuntu package manager (newer wrapper around apt-get/apt-cache). apt [update|upgrade|install|remove|search|show] [<pkg>...]
7 flags update · Refresh the package list from configured repos. Show all
update
Refresh the package list from configured repos.
upgrade
Upgrade installed packages.
install <pkg>
Install one or more packages.
remove <pkg>
Remove (keep config) a package.
purge <pkg>
Remove and delete config files.
autoremove
Drop orphaned dependencies.
search <pat>
Search the package index.
sudo apt update && sudo apt upgrade -ysudo apt install build-essential git curlapt search ripgrep

Always run apt update before apt install — stale indexes cause “package not found” errors. apt is the user-facing tool; apt-get is the more scriptable stable interface (preferred in CI).

apt-get, dpkg
🐧🛡🤖
brew Homebrew package manager for macOS (and Linux via Linuxbrew). brew [install|uninstall|upgrade|search|info|services] [<pkg>...]
6 flags install <pkg> · Install a formula. Show all
install <pkg>
Install a formula.
install --cask <pkg>
Install a GUI app (cask).
uninstall <pkg>
Remove a package.
upgrade
Upgrade everything (or a single named pkg).
search <pat>
Search formulae and casks.
services [start|stop|restart] <pkg>
Manage launchd-driven services (macOS).
brew install jq ripgrep fzfbrew install --cask visual-studio-codebrew services restart postgresql@14

Don’t sudo brew — Homebrew is designed to install into a user-writable prefix and refuses elevated runs.

port, apt
🍎🐧⚙️
pacman Arch Linux package manager. pacman [-S|-R|-Q|-Sy|-Syu|-Ss] [<pkg>...]
7 flags -S <pkg> · Install or upgrade a package. Show all
-S <pkg>
Install or upgrade a package.
-Sy
Refresh the package database.
-Syu
Refresh + full system upgrade.
-R <pkg>
Remove a package.
-Rns <pkg>
Remove + deps + config files.
-Ss <pat>
Search remote packages.
-Qi <pkg>
Show installed-package info.
sudo pacman -Syusudo pacman -S neovim ripgreppacman -Ss ^rust$

Never run pacman -Sy <pkg> on Arch — partial upgrades break dependency chains. Always -Syu.

yay, paru, dnf
🐧🛡
pip Install Python packages from PyPI (or sources). pip [install|uninstall|list|show|freeze] [<pkg>...]
7 flags install <pkg> · Install a package. Show all
install <pkg>
Install a package.
install -r requirements.txt
Install everything listed in the file.
install -e <path>
Editable install (changes in source reflect immediately).
install --user <pkg>
Install into the user site, not the system.
uninstall <pkg>
Remove a package.
freeze
Dump installed package versions in requirements format.
list --outdated
Show packages with newer releases available.
pip install requestspip install -r requirements.txtpip freeze > requirements.txt

Don’t pip install as root on a system Python — you’ll collide with the distro package manager (apt, dnf). Use python -m venv .venv && . .venv/bin/activate, or pipx for CLI tools, or --user. On modern Debian/Ubuntu, system Python is “externally managed” and pip refuses without --break-system-packages.

pipx, uv, poetry
⚙️
npm Node.js package manager. npm [install|uninstall|update|run|publish|init] [<pkg>...]
8 flags install <pkg> · Install into ./node_modules and add to package.... Show all
install <pkg>
Install into ./node_modules and add to package.json.
install -g <pkg>
Install globally (system-wide CLI tools).
install --save-dev <pkg>
Add as devDependency.
install
Install everything in package.json into ./node_modules.
ci
Clean install — installs exactly what package-lock.json says.
run <script>
Run a script defined in package.json scripts.
update [<pkg>]
Update within semver ranges in package.json.
outdated
List packages with newer releases available.
npm installnpm install --save-dev typescriptnpm cinpm run build

Use npm ci in CI — it errors instead of mutating package-lock.json, and it’s faster. Don’t mix npm and yarn/pnpm in the same repo.

npx, pnpm, yarn
⚙️
npx Run a one-off npm package binary without installing it globally. npx [-y] <package>[@version] [args...]
3 flags -y / --yes · Auto-accept install prompt. Show all
-y / --yes
Auto-accept install prompt.
<pkg>@<ver>
Pin a specific version.
--no
Don't attempt to install; only use a local binary.
npx create-vite my-appnpx -y prettier --write "src/**/*.ts"
npm
⚙️
cargo Rust package manager and build tool. cargo [new|build|run|test|add|publish] [<args>...]
6 flags new <name> · Create a new project. Show all
new <name>
Create a new project.
build [--release]
Compile (release adds optimisation, removes debug).
run [-- <args>]
Build and execute (args after -- go to the binary).
test
Run unit and integration tests.
add <crate>
Add a dependency to Cargo.toml.
install <crate>
Install a binary crate globally (~/.cargo/bin).
cargo new hello && cd hellocargo build --releasecargo install ripgrep
rustup
⚙️
bundle Ruby's Bundler — manage gem dependencies per project. bundle [install|update|exec|add] [<gem>...]
4 flags install · Install everything in Gemfile.lock. Show all
install
Install everything in Gemfile.lock.
update [<gem>]
Update gems within Gemfile constraints.
exec <cmd>
Run a command in the bundle context.
add <gem>
Add a gem to the Gemfile and install it.
bundle installbundle exec rake testbundle exec jekyll serve
gem
⚙️
tar Tape archiver — bundle (and optionally compress) directories. tar [c|x|t] [v] [z|j|J] [-f <archive>] [<files>...]
10 flags c · Create a new archive. Show all
c
Create a new archive.
x
Extract from an archive.
t
List contents.
v
Verbose — list each file.
f <archive>
Archive filename (- for stdin/stdout).
z
Compress with gzip (.tar.gz / .tgz).
j
Compress with bzip2 (.tar.bz2).
J
Compress with xz (.tar.xz).
-C <dir>
Change to dir before reading/writing (great for relative paths).
--exclude=<pat>
Skip files matching the glob.
tar czvf backup.tar.gz ~/Documentstar xzvf backup.tar.gz -C /tmp/restoretar tzvf backup.tar.gz | head

Argument order matters with single-letter flags — c, x, t come first; f <archive> must directly precede the filename. Long options (--create, --extract) are more forgiving. Always verify -C when extracting untrusted archives — tarballs can contain absolute paths or ../ traversals (the classic “tar slip” attack).

gzip, xz, zip
🐧🍎⚙️🤖
zip Create a ZIP archive (cross-platform). zip [-r] [-9] [-e] <archive>.zip <files>...
4 flags -r · Recurse into directories. Show all
-r
Recurse into directories.
-9
Best compression.
-e
Encrypt with a password (weak ZipCrypto — use 7z for real security).
-x <pat>
Exclude files matching pattern.
zip -r project.zip ./srczip -9 -r site.zip _site -x '*.DS_Store'
unzip, tar, 7z
🐧🍎🪟⚙️🤖
unzip Extract files from a ZIP archive. unzip [-l] [-o] [-d <dir>] <archive>.zip [<files>...]
4 flags -l · List contents without extracting. Show all
-l
List contents without extracting.
-o
Overwrite existing files without prompting.
-d <dir>
Extract into the given directory.
-q
Quiet.
unzip download.zipunzip -l backup.zipunzip -d /tmp/extract pkg.zip
zip, tar, 7z
🐧🍎🪟⚙️🤖
gzip Single-file gzip compression (.gz). gzip [-d] [-k] [-<level>] <file>...
4 flags -d / gunzip · Decompress. Show all
-d / gunzip
Decompress.
-k
Keep the original file (gzip deletes it by default).
-<1..9>
Compression level (1=fast, 9=small).
-r
Recursively compress files in a directory.
gzip server.loggunzip backup.sql.gzgzip -9k large.bin

gzip works on one file at a time. For multiple files bundle with tar first (tar czf bundle.tar.gz dir/) — that’s the .tar.gz convention.

tar, xz, bzip2
🐧🍎⚙️🤖
7z 7-Zip — high-ratio compression, supports many archive formats. 7z [a|x|l] [-p<pwd>] <archive>.7z [<files>...]
6 flags a · Add to (or create) an archive. Show all
a
Add to (or create) an archive.
x
Extract preserving full paths.
e
Extract to current directory, ignoring paths.
l
List contents.
-p<pwd>
Set/use a password.
-mhe=on
Encrypt filenames too (with password).
7z a backup.7z ./project7z x archive.7z7z a -p -mhe=on secure.7z secrets/
zip, tar
🐧🍎🪟⚙️
xz LZMA2 compression — small archives at the cost of CPU time. xz [-d] [-k] [-<level>] <file>
4 flags -d / unxz · Decompress. Show all
-d / unxz
Decompress.
-k
Keep the original file.
-T <n>
Use n threads (0 = auto, all cores).
-<1..9>
Compression level (default 6; 9e is extreme).
xz -T0 big.tarunxz dump.sql.xztar cJf snap.tar.xz ./project
gzip, zstd, tar
🐧🍎⚙️
sudo Run a single command as another user (default: root). sudo [-i|-u <user>|-E|-k] <cmd> [args...]
6 flags -i · Open an interactive root shell (simulates a fre... Show all
-i
Open an interactive root shell (simulates a fresh login).
-s
Run shell as target user, keep current $PWD/environment.
-u <user>
Run as a non-root user.
-E
Preserve calling user's environment (subject to /etc/sudoers).
-k
Invalidate cached credentials (re-prompt next time).
-v
Refresh credential timestamp without running anything.
sudo apt updatesudo -u postgres psqlsudo -i

sudo cmd >> /etc/file doesn’t work — the redirect is your unprivileged shell. Use echo … | sudo tee -a /etc/file instead. Edit /etc/sudoers only via visudo so syntax errors don’t lock you out.

su, doas, visudo
🐧🍎⚙️🛡🤖
chmod Change file permissions. chmod [<mode>|<symbolic>] <file>...
5 flags <octal> · Three or four octal digits — owner, group, othe... Show all
<octal>
Three or four octal digits — owner, group, others (+ setuid/sticky).
u/g/o/a
Target: user, group, others, all.
+/-/=
Add / remove / set permissions.
r/w/x
Read / write / execute.
-R
Recurse into directories.
chmod 600 ~/.ssh/id_ed25519chmod -R u+rwX,go+rX,go-w site/chmod +x scripts/deploy.sh

Octal cheat sheet: r=4 w=2 x=1. 755 is “owner rwx, others rx” (the default for executables and dirs); 644 is “owner rw, others r” (regular files); 600 is “owner only” (private keys, .env). Capital X in symbolic mode means “x on dirs but not regular files unless already executable” — exactly what you want with -R.

chown, umask, stat
🐧🍎⚙️🤖
chown Change file owner and / or group. chown [-R] [<user>][:<group>] <file>...
5 flags <user> · New owner. Show all
<user>
New owner.
:<group>
New group only (keep owner).
<user>:<group>
Both at once.
-R
Recursive.
-h
Act on the symlink itself, not its target.
sudo chown -R www-data:www-data /var/www/sitesudo chown :staff shared.log
chmod, chgrp
🐧🍎⚙️🛡
umask Show or set the default permission mask for new files. umask [<octal>]
umaskumask 077

Umask is subtracted from the default base mode (666 for files, 777 for dirs). umask 022 → new files 644, new dirs 755 (the typical default). umask 077 → owner-only, useful for paranoid home dirs.

chmod
⚙️
df Report filesystem disk space usage. df [-h] [-T] [-i] [<path>]
4 flags -h · Human-readable (K, M, G). Show all
-h
Human-readable (K, M, G).
-H
Like -h but powers of 1000 instead of 1024.
-T
Include filesystem type.
-i
Show inode usage instead of block usage.
df -hdf -hT /df -i

“No space left on device” can mean blocks OR inodes — check df -i too. Lots of small files can exhaust inodes well before blocks fill up.

du, lsblk
🐧🍎⚙️🤖
du Estimate file space usage (per directory). du [-h] [-s] [-d <depth>] [<path>...]
5 flags -h · Human-readable sizes. Show all
-h
Human-readable sizes.
-s
Summary — one total per arg.
-d <n>
Max depth to descend.
-a
Include individual files, not just directories.
--exclude=<pat>
Skip paths matching the glob.
du -sh *du -h -d 1 ~ | sort -hdu -sh --exclude='*.log' /var/lib

du -sh * misses dotfiles — use du -sh .[!.]* * to include them. ncdu is an interactive front end worth installing if you’re hunting space hogs.

df, ncdu
🐧🍎⚙️🤖
mount Mount a filesystem at a directory. mount [-t <type>] [-o <opts>] <device> <mountpoint>
3 flags -t <type> · Filesystem type (ext4, xfs, nfs, cifs, …); usua... Show all
-t <type>
Filesystem type (ext4, xfs, nfs, cifs, …); usually auto-detected.
-o <opts>
Comma-separated options (ro, noexec, uid=…, vers=4…).
-a
Mount everything in /etc/fstab (used at boot).
sudo mount /dev/sdb1 /mnt/usbsudo mount -t nfs nas.local:/data /mnt/nasmount  # show current mounts
umount, lsblk, fstab
🐧🍎⚙️🛡
umount Unmount a filesystem. umount [-l] [-f] <mountpoint|device>
2 flags
-l
Lazy — detach now, clean up when no longer busy.
-f
Force (mostly NFS-only).
sudo umount /mnt/usbsudo umount -l /mnt/stale

“Target is busy” usually means a shell is cd‘d into the mount or a process has an open file. lsof +D /mnt/usb or fuser -m /mnt/usb tells you who.

mount, fuser, lsof
🐧🍎⚙️🛡
lsblk List block devices in a tree (disks → partitions → mappings). lsblk [-f] [-p] [-o <cols>]
3 flags -f · Include filesystem type, UUID, label. Show all
-f
Include filesystem type, UUID, label.
-p
Print full paths (/dev/sda1).
-o <cols>
Custom columns (NAME,SIZE,FSTYPE,MOUNTPOINT,…).
lsblklsblk -f
df, blkid, fdisk
🐧
free Show memory usage (RAM and swap). free [-h] [-s <sec>] [-c <count>]
3 flags -h · Human-readable sizes. Show all
-h
Human-readable sizes.
-m / -g
Megabytes / gigabytes.
-s <sec>
Repeat every n seconds (loop).
free -hfree -h -s 2

available is what you actually have — free excludes cache that the kernel will reclaim on demand. Linux uses free RAM as cache aggressively; “low free RAM” is usually fine.

top, vmstat
🐧
uname Print system / kernel info. uname [-a|-r|-s|-m]
4 flags -a · Everything: kernel, hostname, kernel version, a... Show all
-a
Everything: kernel, hostname, kernel version, arch, OS.
-r
Kernel release.
-s
Kernel name (Linux / Darwin / …).
-m
Machine architecture (x86_64, arm64, …).
uname -auname -m
lsb_release, hostnamectl
🐧🍎⚙️🤖
id Print the calling user's UID, GID, and group memberships. id [-u|-g|-G|-n] [<user>]
4 flags -u · Effective UID only. Show all
-u
Effective UID only.
-g
Effective GID only.
-G
All group IDs.
-n
Print names instead of numeric IDs (combine with -u/-g/-G).
idid -unid alice
whoami, groups
🐧🍎⚙️🤖
echo Print arguments to stdout. echo [-n] [-e] <string>...
2 flags
-n
Do not append a trailing newline.
-e
Interpret backslash escapes (\n, \t, …).
echo "Hello, $USER"echo -n waiting && sleep 1echo -e "line1\nline2"

echo is a shell builtin AND a binary; behaviour differs slightly across both. For anything beyond trivial output, prefer printf — it’s portable, supports format strings, and doesn’t quietly interpret -e/-n as data.

printf
⚙️
printf Format and print — like C's printf. printf <format> [<arg>...]
printf "%s: %d\n" "errors" 0printf '%-20s %s\n' name email
echo
⚙️
export Mark a shell variable as exported to child processes. export [<name>=<value>] [<name>...]
export EDITOR=nvimexport PATH="$HOME/.local/bin:$PATH"export -p   # list exported vars

An assignment without export (FOO=bar) sets a shell variable that child processes will not see. FOO=bar cmd exports for that single invocation only — clean and useful.

env, unset
⚙️
env Print the environment, or run a command with a modified one. env [-i] [<name>=<value>...] [<cmd> [args...]]
2 flags
-i
Start with an empty environment.
-u <name>
Remove a variable before running cmd.
env | sortenv -i PATH=/usr/bin BAR=baz ./script.shenv DEBUG=1 npm test

The shebang line #!/usr/bin/env python3 uses env to look up Python in PATH — portable across distros that install Python in different places.

export, printenv
⚙️
alias Create a shorthand for a longer command. alias [<name>='<replacement>']
alias ll='ls -lah'alias gst='git status -sb'alias  # list all

Aliases are shell-local — define them in ~/.bashrc / ~/.zshrc for persistence. They don’t expand inside scripts run with #!/bin/bash unless you enable shopt -s expand_aliases; use a function instead for script-level reuse.

unalias, function
⚙️
history Show or manipulate the command history. history [-c] [-d <offset>] [<count>]
3 flags -c · Clear current session's history. Show all
-c
Clear current session's history.
-d <n>
Delete entry at offset n.
-w
Write current session to the history file.
historyhistory | grep ssh!42   # re-run history entry 42

Bash truncates history to HISTSIZE entries; the file to HISTFILESIZE. Multi-shell users want HISTCONTROL=ignoreboth and shopt -s histappend to avoid clobbering history when several shells exit at once.

alias
⚙️
which Show the full path to a command (or that it's an alias / builtin). which [-a] <name>
1 flag
-a
Print all matches in PATH, not just the first.
which python3which -a node

which doesn’t know about aliases or shell functions — type does. Prefer command -v in scripts (POSIX, portable, predictable).

type, whereis, command
🐧🍎⚙️🤖
type Tell you what a name is — alias, builtin, function, or external binary. type [-a] [-t] <name>...
2 flags
-a
All matches (aliases, builtins, AND each binary in PATH).
-t
Just the kind (alias / keyword / function / builtin / file).
type lstype -a echotype -t which
which, command
⚙️
man Show the manual page for a command, syscall, or function. man [<section>] <name>
3 flags <section> · Section number: 1=commands, 2=syscalls, 3=libc,... Show all
<section>
Section number: 1=commands, 2=syscalls, 3=libc, 5=files, 7=misc, 8=admin.
-k <kw>
Keyword search (same as apropos).
-f <name>
One-line description (same as whatis).
man sshman 5 ssh_configman -k ssh

Inside man: /pattern search, n/N next/prev, q quit. For colourised man pages set MANPAGER='less -R' and a colour-aware LESS_TERMCAP_* set in your shell init. tldr is a friendlier “example-first” alternative.

apropos, whatis, tldr
🐧🍎⚙️🤖
read Read one line from stdin into shell variables. read [-p <prompt>] [-s] [-r] [-t <sec>] [-a <arr>] <var>...
5 flags -p <prompt> · Print the prompt before reading. Show all
-p <prompt>
Print the prompt before reading.
-s
Silent — don't echo (for passwords).
-r
Raw — don't interpret backslashes.
-t <sec>
Timeout.
-a <arr>
Read into an array, splitting on IFS.
read -rp "Name: " name && echo "hi $name"read -srp "Pass: " pw

Always use read -r in scripts — without it, backslashes get interpreted as line continuations. while IFS= read -r line; do …; done < file is the canonical loop for reading a file line by line in bash.

readarray, mapfile
⚙️
Redirection idioms Plumb stdin / stdout / stderr to files, pipes, and each other. cmd [> file] [>> file] [< file] [2> file] [2>&1] [<<EOF...EOF] [<(cmd)]
10 flags > file · Redirect stdout to file (overwrite). Show all
> file
Redirect stdout to file (overwrite).
>> file
Append stdout to file.
< file
Use file as stdin.
2> file
Redirect stderr.
2>&1
Merge stderr into stdout (must come AFTER any > redirect).
&> file
Redirect both stdout and stderr (bash shorthand).
| cmd
Pipe stdout to cmd's stdin.
<<EOF ... EOF
Heredoc — multi-line stdin terminated by EOF.
<<<"<word>"
Herestring — single-line stdin from .
<(cmd)
Process substitution — treat cmd's stdout as a file.
make build > build.log 2>&1cmd 2>/dev/null    # silence errorsdiff <(sort a.txt) <(sort b.txt)cat <<EOF > config.yml
key: value
EOF

Order matters: cmd > file 2>&1 sends both to file, but cmd 2>&1 > file sends stderr to the original stdout (terminal) and stdout to the file. &> is bash-only; portable scripts should use > file 2>&1.

tee, xargs
⚙️
python3 Run Python — REPL, scripts, modules, one-liners. python3 [-i] [-c "<code>"] [-m <module>] [<script> [args]]
5 flags -c "<code>" · Execute a one-liner. Show all
-c "<code>"
Execute a one-liner.
-m <mod>
Run a module as a script (python3 -m http.server).
-i
Drop into REPL after running the script (great for debugging).
-u
Unbuffered stdout/stderr — see prints immediately in pipes.
-V / --version
Print version and exit.
python3 -c "import json,sys; print(json.load(sys.stdin)['ok'])"python3 -m http.server 8000python3 -i debug.py

System Python and your project’s Python are different — use python3 -m venv .venv && . .venv/bin/activate per project. On macOS, python (no 3) usually doesn’t exist; always use python3. uv / pyenv manage parallel interpreter versions.

pip, pipx, uv, pyenv
⚙️
node Run JavaScript with Node.js — REPL, scripts, one-liners. node [-e "<code>"] [-p "<expr>"] [<script> [args]]
5 flags -e "<code>" · Execute the code string. Show all
-e "<code>"
Execute the code string.
-p "<expr>"
Evaluate and print the expression's result.
-r <mod>
Require the module before running (for shims).
--inspect
Enable the Chrome DevTools debugger.
-v / --version
Print version.
node -e "console.log(crypto.randomUUID())"node -p "process.versions"node --inspect server.js
npm, npx, deno, bun
⚙️
ruby Run Ruby — REPL via irb, scripts, one-liners. ruby [-e "<code>"] [-n|-p] [-l] [<script> [args]]
5 flags -e "<code>" · Execute a one-liner. Show all
-e "<code>"
Execute a one-liner.
-n
Wrap script in 'while gets; …; end' (auto line loop).
-p
Like -n but auto-prints $_ each iteration.
-l
Chomp newlines + add newline on print (line-mode).
-r <lib>
Require a library before running.
ruby -e "puts 'hi'"ruby -pe 'gsub(/foo/, "bar")' input.txt
irb, gem, bundle
⚙️
irb Interactive Ruby REPL. irb [-r <lib>] [--simple-prompt]
2 flags
-r <lib>
Require a library on start.
--simple-prompt
Minimal prompt.
irbirb -r json
ruby, pry
⚙️
bash GNU Bash shell — interactive or batch. bash [-c "<cmd>"] [-i] [-l] [<script> [args]]
7 flags -c "<cmd>" · Execute one command string then exit. Show all
-c "<cmd>"
Execute one command string then exit.
-i
Force interactive mode.
-l / --login
Login shell — sources /etc/profile + ~/.bash_profile.
-x
Trace each command before execution (debugging).
-e
Exit on first error (set -e at script start does the same).
-u
Treat unset variables as an error.
-o pipefail
Pipeline fails if any stage fails, not just the last.
bash -c 'echo $$'bash -lc 'env | grep PATH'bash -euo pipefail script.sh

The “strict mode” trio set -euo pipefail at the top of every script catches a huge class of bugs early — unset vars typoed as commands, partial-pipeline failures silently ignored, etc. macOS ships bash 3.2 (2007) under /bin/bashbrew install bash for the modern one at /opt/homebrew/bin/bash.

zsh, sh, dash
🐧🍎⚙️🤖
zsh Z shell — bash-compatible-ish with extras (globbing, prompts, plugins). zsh [-c "<cmd>"] [-i] [<script> [args]]
zsh -c 'echo $ZSH_VERSION'

Default shell on macOS since Catalina. Most bash scripts work unchanged but a few subtle differences exist (word splitting on unquoted vars, glob behaviour). Pin scripts to bash with #!/usr/bin/env bash when portability matters.

bash, oh-my-zsh
🐧🍎⚙️🤖
Shebang lines The #! interpreter directive at the top of a script. #!<path-to-interpreter> [<flags>]
#!/usr/bin/env bash#!/usr/bin/env python3#!/usr/bin/env -S node --experimental-vm-modules#!/bin/sh

Use #!/usr/bin/env <interp> for portability — it finds the interpreter via PATH instead of hard-coding /usr/local/bin/.... Linux limits the shebang line to 128 chars and historically only allows one arg to the interpreter — env -S (GNU coreutils ≥ 8.30) splits a second arg-string for you.

bash, python3, node
🐧🍎⚙️🤖
docker run Create and start a container from an image. docker run [-d] [-it] [--rm] [-p <h>:<c>] [-v <h>:<c>] [-e <k>=<v>] <image> [<cmd>]
10 flags -d · Detached — run in the background. Show all
-d
Detached — run in the background.
-it
Interactive (-i) + allocate a TTY (-t).
--rm
Auto-remove the container when it exits.
--name <name>
Assign a name (instead of a random one).
-p <hp>:<cp>
Publish a container port to the host.
-v <hpath>:<cpath>[:ro]
Mount a host path into the container (optionally read-only).
-e <k>=<v>
Set an environment variable inside the container.
--env-file <file>
Load env vars from a file.
--network <net>
Attach to a specific docker network.
-u <uid>[:<gid>]
Run as a non-root user / group.
docker run --rm -it ubuntu:24.04 bashdocker run -d --name web -p 8080:80 nginx:alpinedocker run --rm -v $PWD:/app -w /app node:22 npm test

Default users inside containers are often root, even when the host user isn’t. Anything written into a bind-mount lands on disk as root. Pass -u "$(id -u):$(id -g)" to match your host UID, or build the image with a non-root USER.

docker exec, docker ps, docker stop
⚙️
docker ps List containers. docker ps [-a] [--filter <f>] [--format <fmt>]
4 flags -a · Include stopped containers. Show all
-a
Include stopped containers.
-q
Quiet — IDs only (handy with xargs).
--filter <k>=<v>
Filter (status=exited, name=web, ancestor=nginx).
--format <go-template>
Custom output (e.g. 'table {{.Names}}\t{{.Image}}').
docker psdocker ps -aq --filter status=exited | xargs docker rmdocker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
docker rm, docker stop
⚙️
docker build Build an image from a Dockerfile. docker build [-t <tag>] [-f <Dockerfile>] [--build-arg <k>=<v>] [--target <stage>] <context>
6 flags -t <tag> · Tag the resulting image (name:version). Show all
-t <tag>
Tag the resulting image (name:version).
-f <file>
Use a Dockerfile at a non-standard path.
--build-arg <k>=<v>
Pass an ARG into the build.
--target <stage>
Stop at a named stage in a multi-stage build.
--no-cache
Disable the layer cache.
--platform <plat>
Build for a specific platform (linux/arm64, linux/amd64).
docker build -t myapp:dev .docker build -f Dockerfile.prod --target runtime -t myapp:prod .docker build --platform linux/amd64 -t myapp:x86 .

The context (.) is uploaded to the daemon before the build starts — add a .dockerignore to exclude node_modules, .git, etc. or you’ll send gigabytes on every build. Use BuildKit (DOCKER_BUILDKIT=1 on older Docker, default since 23.0) for cache mounts, parallel stages, and secret mounts.

docker buildx, docker push
⚙️
docker exec Run a command inside an already-running container. docker exec [-it] [-u <user>] <container> <cmd> [args...]
4 flags -it · Interactive + TTY (for shells). Show all
-it
Interactive + TTY (for shells).
-u <user>
Run as a different user inside the container.
-e <k>=<v>
Add an env var for this command only.
-w <dir>
Working directory.
docker exec -it web shdocker exec -u root web apt updatedocker exec web env | sort
docker run, docker logs
⚙️
docker logs Show stdout / stderr of a container. docker logs [-f] [--tail <n>] [--since <t>] <container>
4 flags -f · Follow — keep streaming. Show all
-f
Follow — keep streaming.
--tail <n>
Only the last n lines.
--since <time>
Lines newer than e.g. '10m', '2024-01-01'.
-t
Prefix each line with a timestamp.
docker logs -f --tail 100 webdocker logs --since 1h --tail 50 db
docker ps, docker exec
⚙️
docker compose Define and run multi-container applications via a YAML file. docker compose [-f <file>] [up|down|ps|logs|exec] [args...]
8 flags up · Build + create + start everything in compose.yml. Show all
up
Build + create + start everything in compose.yml.
up -d
Detached — return after services start.
down
Stop + remove containers, networks, volumes (with -v).
ps
List services and their state.
logs [-f]
Aggregate logs from all services.
exec <svc> <cmd>
Run a command in a named service.
build [--no-cache]
(Re)build images for services with a build: stanza.
-f <file>
Use a non-default compose file (default: compose.yml or docker-compose.yml).
docker compose up -ddocker compose logs -f web dbdocker compose exec db psql -U postgres

docker compose (v2, plugin) and docker-compose (v1, separate Python binary) take nearly identical args; v1 is legacy and missing from new installs. compose.yml is the v3+ filename, but most projects still ship docker-compose.yml.

docker run, docker build
⚙️
podman Daemonless, root-less Docker-compatible container engine. podman <command> [args...]
podman run --rm -it alpine shpodman build -t myapp .alias docker=podman

CLI is a near-superset of Docker’s (most docker commands work via alias docker=podman). Default is rootless — uses user namespaces under the hood, so port-mapping below 1024 won’t work without extra config. On macOS, runs a tiny Linux VM (podman-machine) behind the scenes.

docker run, docker build
🐧🍎⚙️
kubectl Talk to a Kubernetes cluster — inspect, deploy, exec, log. kubectl [-n <ns>] [get|describe|logs|exec|apply|delete|edit] <resource> [args...]
5 flags -n <namespace> · Operate inside a non-default namespace. Show all
-n <namespace>
Operate inside a non-default namespace.
--context <ctx>
Use a specific kubeconfig context.
-l <key>=<val>
Label selector.
-o yaml|json|wide
Output format.
--all-namespaces / -A
Operate across every namespace.
kubectl get pods -Akubectl logs -f deploy/web -n productionkubectl exec -it pod/web-abc123 -- shkubectl apply -f manifest.yaml

Always confirm kubectl config current-context before destructive commands — landing a kubectl delete on production because you forgot to switch contexts is a classic footgun. kubectx + kubens from ahmetb/kubectx make context/namespace switching ergonomic.

kubectx, helm, k9s
⚙️