A Linux commands cheat sheet is a quick-reference list of terminal commands you reuse every day—navigate folders, copy files, install packages, and manage services—without re-learning flags from scratch. On Ubuntu, open Terminal, type a command, press Enter, and use man command or command --help for details (Ubuntu’s official CLI cheat sheet follows the same idea).
This page is built as a dense table reference (Bash on Ubuntu/Debian-family). It complements longer tutorials: scan a section, copy a line, then check man before anything destructive.
Jump to: navigation · files · search · permissions · apt · processes · network · pipes · history/aliases · one-liners

Help (Always First)
| Command | Meaning |
|---|---|
man cmd | Full manual (q quit) |
man -k keyword | Search man descriptions |
cmd --help | Short usage |
whatis cmd | One-line summary |
which cmd | Path to executable |
type cmd | Alias, builtin, or binary? |
Navigation
| Command | Meaning |
|---|---|
pwd | Print working directory |
ls | List files |
ls -l | Long list (perms, owner, size) |
ls -a | Include hidden (.file) |
ls -la | Long + hidden |
ls -lh | Human-readable sizes |
cd dir | Change directory |
cd .. | Up one level |
cd ~ / cd | Home |
cd - | Previous directory |
cd / | Root |
tree | Directory tree (if installed) |
tree -L 2 | Tree depth 2 |
Files and Directories
| Command | Meaning |
|---|---|
mkdir name | Make directory |
mkdir -p a/b/c | Make nested dirs |
rmdir name | Remove empty directory |
touch file | Create empty / update time |
cp src dest | Copy file |
cp -a src/ dest/ | Recursive copy, keep attrs |
mv old new | Move / rename |
rm file | Delete file |
rm -r dir/ | Delete directory tree |
rm -i file | Prompt before delete |
cat file | Print file |
less file | Page viewer |
head -n 20 file | First 20 lines |
tail -n 20 file | Last 20 lines |
tail -f log | Follow log |
wc -l file | Count lines |
file path | Guess file type |
ln -s target link | Symbolic link |
Danger zone: avoid rm -rf / and unquoted globs as root.
Search
| Command | Meaning |
|---|---|
grep pattern file | Match lines in a file |
grep -R pattern dir/ | Recursive search (Ask Ubuntu classic) |
grep -Ri pattern dir/ | Case-insensitive recursive |
grep -n pattern file | Show line numbers |
find . -name "*.pdf" | Find by name |
find . -mtime -1 | Modified last day |
find . -type f -empty | Empty files |
locate name | Fast DB search (if mlocate installed) |
Permissions and Users
| Command | Meaning |
|---|---|
sudo cmd | Run as admin |
sudo -i | Root shell |
whoami | Current user |
id | UID/GIDs |
chmod 644 file | rw-r--r-- |
chmod u+x script | Add execute for owner |
chmod -R u+rwX dir/ | Recursive (careful) |
chown user:group file | Change owner |
umask | Default permission mask |
passwd | Change your password |
groups | Your groups |
chmod vs chown (Ask Ubuntu): chmod = can they access it?; chown = who owns it?
Packages (APT + Snap)
| Command | Meaning |
|---|---|
sudo apt update | Refresh indexes |
sudo apt upgrade | Upgrade packages |
apt search kw | Search packages |
apt show pkg | Package info |
sudo apt install pkg | Install |
sudo apt remove pkg | Remove (keep configs) |
sudo apt purge pkg | Remove + configs |
sudo apt autoremove | Drop unused deps |
apt list --installed | Installed packages |
sudo snap install pkg | Snap install |
snap list | Installed snaps |
sudo snap refresh | Update snaps |
Processes and Services
| Command | Meaning |
|---|---|
ps aux | Process snapshot |
top / htop | Live monitor |
kill PID | Terminate |
kill -9 PID | Force kill |
pkill name | Kill by name |
systemctl status svc | Service status |
sudo systemctl start svc | Start |
sudo systemctl stop svc | Stop |
sudo systemctl restart svc | Restart |
sudo systemctl enable svc | Enable at boot |
systemctl list-unit-files --state=enabled | Enabled units |
journalctl -u svc -f | Follow service logs |
Disk, Memory, System Info
| Command | Meaning |
|---|---|
df -h | Disk free (human) |
du -sh * | Folder sizes here |
du -sh . | Current dir size |
free -h | RAM / swap |
uname -a | Kernel info |
hostnamectl | Host / OS info |
uptime | Load / uptime |
lsblk | Block devices |
lscpu | CPU info |
Network
| Command | Meaning |
|---|---|
ip a | Addresses / interfaces |
ip r | Routes |
ping -c 4 host | Connectivity test |
curl -I URL | HTTP headers |
wget URL | Download |
ssh user@host | Remote shell |
scp file user@host:path | Copy over SSH |
ss -tulpn | Listening sockets |
sudo ufw status | Firewall status (if UFW) |
Archives
| Command | Meaning |
|---|---|
tar -xzf a.tar.gz | Extract gzip tarball |
tar -czf a.tar.gz dir/ | Create gzip tarball |
tar -tzf a.tar.gz | List contents |
tar -xJf a.tar.xz | Extract xz tarball |
zip -r a.zip dir/ | Zip folder |
unzip a.zip | Unzip |
Pipes, Redirects, Chaining
From Ubuntu’s CLI-in-depth / cheat sheet:
| Syntax | Meaning |
|---|---|
cmd > file | Overwrite stdout to file |
cmd >> file | Append stdout |
cmd < file | File as stdin |
cmd 2> err.txt | Redirect stderr |
cmd > out 2>&1 | Stdout+stderr to file |
cmd > /dev/null | Discard stdout |
a | b | Pipe a → b |
a && b | b if a succeeds |
a || b | b if a fails |
a ; b | Run both |
cmd & | Background |
$(cmd) | Command substitution |
$((1+2)) | Arithmetic |
Ask Ubuntu preference: use && in install scripts so later steps stop after failure.
Shell History and Aliases
High-traffic Ask Ubuntu topics:
| Command | Meaning |
|---|---|
history | Show command history |
history | grep apt | Search history |
!! | Re-run last command |
sudo !! | Re-run last with sudo |
Ctrl+R | Reverse history search |
alias ll='ls -la' | Temporary alias |
alias | List aliases |
type aliasname | See what an alias runs |
Permanent alias (Ask Ubuntu pattern): add alias ll='ls -la' to ~/.bashrc, then source ~/.bashrc.
Copy-Paste One-Liners
# Update system sudo apt update && sudo apt upgrade -y # Biggest folders in / sudo du -xh / --max-depth=1 | sort -h # Find large files (>100M) find ~ -type f -size +100M -ls # Recycle-safe delete prompt alias rm='rm -i' # Extract then enter tar -xzf project.tar.gz && cd project # Follow auth log sudo journalctl -u ssh -f # Backup home (example) rsync -a --progress ~/Documents/ /media/usb/Documents/
rsync notes from Ask Ubuntu: use --delete only when you intend destination to mirror source; exclude paths with --exclude.
Keyboard / Terminal Survival Keys
| Keys | Action |
|---|---|
| Tab | Autocomplete |
| Ctrl+C | Cancel command |
| Ctrl+D | EOF / exit shell |
| Ctrl+L | Clear screen |
| Ctrl+R | History search |
| Ctrl+Z | Suspend job (fg to resume) |
reset | Fix broken terminal (Ask Ubuntu “typed text invisible”) |
After the Terminal: Documents on Linux
When you need formatted DOCX/XLSX/PDF instead of plain text, install WPS Office for Linux from the official WPS Linux download page. Keep this cheat sheet for system tasks; use WPS for Microsoft Office–compatible files.
FAQ
Is this the same as Ubuntu’s official cheat sheet?
It follows the same structure and commands as Canonical’s command-line cheat sheet, expanded with apt, systemctl, network, archives, and Ask Ubuntu–common one-liners.
How do I print a Linux commands cheat sheet?
Open this page and print, or copy each table into a doc. For a local copy: man pages stay authoritative when flags change.
What should I memorize first?pwd, ls, cd, cp, mv, rm -i, mkdir, grep, find, sudo apt update, man.
How do I extract .tar.gz?tar -xzf file.tar.gz
Where do permanent aliases go?
Usually ~/.bashrc on Ubuntu Bash, then source ~/.bashrc.
Command not found—what next?apt search name, install the package, or check echo $PATH / typos with which/type.


