Bash Cheat Sheet
Searchable reference for everyday Bash commands.
| Command | Description |
|---|---|
| ls -la | List files including hidden, long format |
| cd <dir> | Change directory |
| pwd | Print working directory |
| mkdir -p a/b/c | Make nested directories |
| rm -rf <dir> | Remove directory recursively |
| cp -r <src> <dst> | Copy directory recursively |
| mv <src> <dst> | Move / rename |
| cat <file> | Print file contents |
| less <file> | Page through a file |
| head -n 20 <file> | First 20 lines |
| tail -f <file> | Follow file output |
| grep -r 'pat' . | Recursive grep |
| find . -name '*.cs' | Find files by name |
| sed 's/foo/bar/g' f | Stream edit (replace globally) |
| awk '{print $1}' f | Print first column |
| chmod 755 <file> | Set file permissions |
| chown user:group f | Change file owner |
| ps aux | grep app | Find running process |
| kill -9 <pid> | Force-kill process |
| df -h | Disk space (human readable) |
| du -sh <dir> | Folder size |
| tar -czf a.tgz d/ | Create gzipped tar |
| tar -xzf a.tgz | Extract gzipped tar |
| curl -fsSL url | Quietly fetch and pipe |
| wget url | Download a URL |
| ssh user@host | SSH into host |
| scp f user@host:/p | Copy over SSH |
| export VAR=value | Set environment variable |
| history | grep cmd | Search shell history |
| man <cmd> | Show command manual |
About this tool
Common file, process, archive and shell commands with one-line descriptions.