Linux & Bash Commands Cheat Sheet

90+ essential Linux and Bash commands — search, filter by category, and copy with one click

Tip: Press Ctrl+K to focus search. Click any command to copy it to clipboard. Use category filters to narrow results.

⚡ Power User Tips

Chain commands with &&

Run the next command only if the previous succeeded: mkdir project && cd project && git init

Run in background with &

Add & at the end: python server.py &. Use jobs to list, fg %1 to bring to foreground.

Use !! for last command

Forgot sudo? Run sudo !! to repeat the last command with sudo. !$ gives the last argument.

Navigate history fast

Press Ctrl+R to reverse-search command history. Type part of any previous command to find it.

Create command aliases

Add to ~/.bashrc: alias ll='ls -la', alias gs='git status'. Run source ~/.bashrc to apply.

Redirect stderr too

command 2>&1 | tee output.log — captures both stdout and stderr while also showing them in the terminal.

Use curly braces for expansion

cp file.txt{,.bak} copies file.txt to file.txt.bak. mkdir -p src/{css,js,img} creates multiple dirs.

Screen / tmux for persistence

Use tmux new -s session or screen to keep processes running after SSH disconnect. Detach with Ctrl+B, D.

Frequently Asked Questions

What are the most important Linux commands to know?
The core commands every Linux user needs: ls, cd, pwd, cp, mv, rm, mkdir, grep, chmod, ps, kill, and ssh. These 12 commands cover 80% of everyday terminal usage. Learn them well before diving into more specialized tools.
How do I find a file in Linux?
Use find . -name "filename" to search from the current directory. Add -type f for files only, -type d for directories. For faster searches, use locate filename (requires running updatedb first). To find files by content, use grep -r "search term" /path.
How do I check disk space in Linux?
df -h shows disk usage for all mounted filesystems in human-readable format. du -sh /path shows the size of a specific directory. du -sh * inside a directory shows sizes of all items. du -sh * | sort -rh | head -10 shows the 10 largest items.
How do I kill a process in Linux?
First find the PID with ps aux | grep processname or pgrep processname. Then: kill PID for graceful stop (SIGTERM), kill -9 PID to force kill (SIGKILL). Shortcuts: pkill processname kills by name, killall processname kills all processes with that name.
How do I change file permissions in Linux?
Use chmod. Common patterns: chmod 755 file (executable, readable by all), chmod 644 file (readable by all, writable only by owner), chmod +x file (add execute permission), chmod -R 755 dir (recursive). Permissions: read=4, write=2, execute=1. Add them together for owner/group/others.
How do I use pipes and redirects in Linux?
Pipes (|) pass output to another command: ls -la | grep .txt | wc -l. Redirects: > writes to file (overwrites), >> appends, < reads from file. 2> redirects stderr, 2>&1 combines stderr with stdout. Example: command > out.txt 2>&1 captures everything.
How do I search for text inside files?
grep "pattern" file.txt — search one file. grep -r "pattern" /dir — recursive search. grep -i — case-insensitive. grep -n — show line numbers. grep -v — show non-matching lines. grep -l — show only filenames. Combine: grep -rn "TODO" . --include="*.py"
What is the difference between apt, yum, and dnf?
These are package managers for different Linux distros. apt / apt-get: Debian, Ubuntu, Mint. yum: older RHEL, CentOS 7. dnf: modern Fedora, RHEL 8+, CentOS 8+. pacman: Arch Linux. brew: macOS (Homebrew). The basic workflow is similar: install, update, search, remove — only the package manager name differs.