linux shell
bash 5+ / POSIX 2017Quick reference for everyday Linux / macOS shell commands: file operations, text processing, permissions, processes, networking, archive and storage — with common options and practical examples.
40 commands
Files & Navigation
pwdPrint the absolute path of the current working directory.
pwdlsList directory contents.
-l long format; -a include hidden; -h human sizes; -t sort by mtime; -r reverse
ls -lah /var/logcd <dir>Change the current working directory.
cd ~/-projects/app && pwdtree <dir>Recursively list a directory as a tree; great for overview (may need install).
-L <n> max depth; -a show hidden; -d dirs only; -I pattern
tree -L 2 -I 'node_modules|.git' .File Operations
mkdir -p <dir>Create a directory (and any missing parents) in one shot.
-p create parents; -v verbose; -m <mode> set permissions
mkdir -p src/components/uicp <src> <dest>Copy files or directories.
-r recursive (for dirs); -i interactive; -v verbose; -p preserve mode/time
cp -rv src/ backup/mv <src> <dest>Move (rename) files or directories.
-i interactive; -v verbose; -n no-overwrite
mv README.md readme.md && mv ../tmp .rm <path>Remove files or directories. ⚠️ there is no trash — double-check paths.
-r recursive; -f force; -i interactive; -v verbose
rm -rf build/ node_modules/ln -s <target> <link>Create a symbolic link at <link> pointing to <target>.
-s symbolic (default: hard); -f overwrite existing; -n do not follow existing
ln -s /opt/app-v2 currenttouch <file>Create an empty file or update its mtime without changing contents.
touch .gitignoreText & Viewing
cat <file>Print the entire contents of a file to stdout.
-n number lines; -A show non-printing chars; -s squeeze blanks
cat -n package.jsonless <file>Open a file in a paginator (use /, n, N to search; q to quit).
-N line numbers; -S no wrap; +F auto-follow tail-like
less -NS /var/log/sysloghead -n 10 <file>Output the first N lines (default 10) of a file.
head -n 30 /etc/passwdtail -n 50 -f <file>Show the last N lines and follow the file as it grows (for logs).
-f follow; -F follow & retry; -n lines (default 10); -c bytes; --pid=PID stop when PID dies
tail -f -n 50 /var/log/nginx/access.logSearch & Filter
grep <pattern> <files>Search lines matching a pattern; supports extended and PCRE regex.
-i case-insensitive; -r recursive; -n line numbers; -v invert; -E extended regex
grep -rni "TODO" src/find <path> -name <pattern>Walk a directory tree and list files matching criteria.
-type f|d; -name glob; -iname case-insensitive; -size +1M; -mtime -7; -maxdepth
find . -type f -name "*.log" -mtime +7 -deleteawk '<prog>' <file>Pattern-action text scanner — slicing columns, summing values, etc.
-F fs field separator; -v var=value; -f script file
awk -F'\t' 'NR>1 {sum+=$3} END {print sum}' data.tsvsed 's/<a>/<b>/' <file>Stream editor — substitution, deletion, insertion per-line.
-i edit in place; -E extended regex; -e combine exprs; s/from/to/[g] [p]
sed -i '' 's/version = "1\.."/version = "1.9"/' pyproject.tomlsort | uniq -c | sort -nrPipeline idiom: count occurrences and sort by frequency descending.
awk '{print $1}' access.log | sort | uniq -c | sort -nr | headPermissions
chmod <mode> <file>Change file permissions (e.g., 755, u+x, g-w, o=r).
-R recursive; --reference=<file> copy mode
chmod -R u=rwX,go=r ./docschown <user>[:<group>] <file>Change file owner and group.
-R recursive; -h affect symlinks (with -R)
chown -R www-data:www-data /var/www/htmlumaskShow/set the default permission mask for newly created files.
-S symbolic; -p umask preserved for portability
umask 022Processes & System
ps auxShow all processes with detailed info (BSD-style columns).
-e all; -f full; -L threads; --sort=-%mem
ps auxf | grep -v grep | grep nginxtop / htopLive, interactive process viewer (htop has nicer UI; may need install).
P/CPU M/MEM sort; k kill; r renice; q quit
htop -u www-datakill [-9|<sig>] <pid>Send a signal to a process. SIGTERM (15) is polite; SIGKILL (9) is forceful.
-9 SIGKILL; -l list signals; -s specify signal by name
kill -TERM 12345 && sleep 2 && kill -9 12345jobs / bg / fg / nohupManage job control — list, background, foreground, run immune to hangups.
nohup ./long-task.sh > out.log 2>&1 &systemctl <verb> <unit>Control systemd services and units (status, start, stop, enable, logs).
status / start / stop / restart / enable / disable; -u <user>
systemctl status nginx && systemctl reload nginxNetwork
wget <url>Non-interactive downloader; recursive / mirror friendly.
-c continue; -q quiet; --no-check-certificate; -r recursive
wget -c https://example.com/big-archive.tar.gzssh <user>@<host> [cmd]Open an SSH session or run a one-off command on a remote host.
-p <port>; -i <key>; -L / -R / -D port forwardings; -N no remote cmd; -f background
ssh -i ~/.ssh/id_ed25519 user@host 'sudo systemctl restart nginx'scp / rsyncCopy files to/from a remote host. rsync is faster for partial / repeated transfers.
scp -r / rsync -avz --progress src/ user@host:/dst/
rsync -avz --progress ./build/ deploy@server:/srv/app/ping / traceroute / ssDiagnose reachability, path and listening sockets.
ping -c N count; ss -tulnp listen info; ss -s summary
ss -tulnp | grep -E ':80|:443'Archive & Compress
tar -czf out.tgz <paths>Create or extract tar archives, optionally with gzip/bzip2/xz.
-c create; -x extract; -t list; -z gzip; -j bzip2; -J xz; -v verbose; -C <dir>
tar -czf - src/ | ssh server 'tar -xzf - -C /srv/app'zip -r out.zip <paths>Create a zip archive recursively.
-r recurse; -9 max compression; -e encrypt; -j junk paths
zip -r9 build-$(date +%Y%m%d).zip dist/unzip [-d <dir>] file.zipExtract a zip archive, optionally to a target directory.
-d target dir; -o overwrite; -l list; -p to stdout; -q quiet
unzip -o build.zip -d ./extractedDisk & Storage
df -hShow mounted filesystem disk space usage, human-readable.
-h human; -T print filesystem type; -i inodes
df -hT /du -sh <path>Estimate file space usage; -s summarizes a directory.
-s summarize; -h human; -a all; --max-depth=N; -x stay on one fs
du -sh node_modules/ build/ .Shell Built-ins
history / !! / !$Browse, replay and re-use previous commands.
history N; !<n> rerun line N; !$ = last arg of last command; !! rerun last
git add . && git commit -m "$(!!)"alias / unaliasDefine or list shell command shortcuts (often in ~/.bashrc / ~/.zshrc).
alias ll='ls -lah' && alias gs='git status'env / export / unsetList, set and clear environment variables for child processes.
export DATABASE_URL=postgres://localhost/dev && env | grep DATABASEHelp
man <cmd> / <cmd> --helpRead the manual page (man) or built-in help for a command.
man -k keyword search; man -t <cmd> print to PDF; --help short usage
man -k 'tar archive'Related command cheatsheets
powershell
Quick reference for PowerShell cmdlets: discovery, file/system, pipeline filtering and selection, networking, remote sessions and modules — with common parameters and practical examples.
34 commands
PowerShell 7+
cmd
Quick reference for the classic Windows Command Prompt (cmd.exe): file/dir operations, text search, system info, networking and batch scripting — with common options and practical examples.
40 commands
Windows cmd.exe 10+
Trademark & Use Notice
These command-line tool cheatsheets are open community references. The names, logos, and trademarks of the tools referenced here (such as Git™, Docker™, Kubernetes®, kubectl, PostgreSQL®, MySQL®, Redis™, MongoDB®, Linux™, PowerShell™, Vim™, and others) are the property of their respective owners and are used here solely for identification and reference purposes.
All content in these cheatsheets is independently authored as a simplified, self-contained reference. It is not affiliated with, endorsed by, or sourced from any official documentation. Command listings, flag descriptions, and examples are original simplifications; for authoritative information please consult the official documentation of each tool.
Command syntax and option flags may differ across tool versions. The version tags shown reflect stable releases; behavior may differ in other versions. This cheatsheet does not imply any preference or recommendation by the trademark holders.
If a trademark or copyright owner believes that any content on this site infringes their rights, please send an email to [email protected]. Upon receiving valid proof of rights, we will modify or remove the relevant content within a reasonable period.
This website assumes no legal liability for any direct or indirect losses arising from the use of information presented on these pages.
About the Linux / POSIX shell
The shell is the command interpreter that turns keystrokes into operating-system actions on every Unix-like system — Linux, macOS, BSD, and the WSL on Windows. The most common shells today are bash (the GNU Bourne-again shell, default on most Linux distros, current line 5.2+), zsh (default on modern macOS since Catalina), and the POSIX-conforming dash / ash that power many embedded Linuxes. The shell exposes a powerful pipeline of small commands — `grep`, `awk`, `sed`, `find`, `xargs`, `sort`, `uniq`, `tee` — and a scripting language with variables, control flow, functions, and process substitution. The Linux shell follows the POSIX 1003.1 standard, which keeps scripts portable across distros when you stick to POSIX features rather than bash-isms. Use the shell for one-off file processing, system administration, build automation, and writing portable scripts; reach for `xargs -0` (not bare `xargs`) when filenames may contain spaces, and always quote `"$var"` to defeat word-splitting. The shell is local: nothing you type leaves your machine unless a command you run explicitly does so (such as `curl` or `ssh`).
Cheatsheet version 1.0.0