Complete Bash and Shell commands cheat sheet for Linux system administration. Covers file operations, text processing, system monitoring, networking, and pipe operations.
Search all Bash / Shell shortcuts interactively
Interactive Shortcut Finder| Shortcut | Action | Description |
|---|---|---|
| ls -la | Detailed list | Show detailed file list including hidden files. |
| cd [path] | Change directory | Navigate to the specified directory. |
| pwd | Current path | Print current working directory. |
| mkdir -p [path] | Create directory | Create directories including parents. |
| cp -r [src] [dst] | Copy | Copy files or directories. |
| mv [src] [dst] | Move/Rename | Move or rename files. |
| rm -rf [path] | Force delete | Force delete files or directories. |
| find . -name [pattern] | Find files | Search for files by name pattern. |
| chmod +x [file] | Make executable | Add execute permission to a file. |
| chown [user]:[group] [file] | Change owner | Change file ownership. |
| Shortcut | Action | Description |
|---|---|---|
| cat [file] | Print file | Print file contents. |
| grep [pattern] [file] | Search text | Search for patterns in files. |
| head -n 20 [file] | First N lines | Show first 20 lines of a file. |
| tail -f [file] | Follow file | Follow the end of a file in real time. |
| wc -l [file] | Count lines | Count lines in a file. |
| sort [file] | Sort | Sort file contents. |
| sed 's/old/new/g' [file] | Find & replace | Find and replace text in files. |
| awk '{print $1}' [file] | Extract fields | Extract specific fields from files. |
| Shortcut | Action | Description |
|---|---|---|
| ps aux | List processes | Show all running processes. |
| top | System monitor | Show real-time system resource usage. |
| kill -9 [PID] | Force kill | Force kill a process. |
| df -h | Disk usage | Show disk usage in human-readable format. |
| du -sh [path] | Directory size | Show total directory size. |
| free -h | Memory usage | Show memory usage. |
| curl [URL] | HTTP request | Send an HTTP request to a URL. |
| ssh [user]@[host] | SSH connect | Connect to a remote server via SSH. |
| scp [file] [user]@[host]:[path] | Remote copy | Copy files remotely via SSH. |
| Shortcut | Action | Description |
|---|---|---|
| [cmd] | [cmd] | Pipe | Pass output of one command as input to another. |
| [cmd] > [file] | Redirect output | Save command output to file (overwrite). |
| [cmd] >> [file] | Append output | Append command output to file. |
| [cmd] 2>&1 | Redirect stderr | Merge error output with standard output. |
| xargs | Pass arguments | Convert stdin to arguments for a command. |
| Shortcut | Action | Description |
|---|---|---|
| Ctrl + A | Start of Line | Moves the cursor to the beginning of the command line. |
| Ctrl + E | End of Line | Moves the cursor to the end of the line. |
| Ctrl + B | Back One Character | Same as Left arrow. |
| Ctrl + F | Forward One Character | Same as Right arrow. |
| Alt + B | Back One Word | Jumps the cursor back a word. |
| Alt + F | Forward One Word | Jumps the cursor forward a word. |
| Ctrl + W | Delete Word Before Cursor | Cuts the previous word into the kill ring. |
| Alt + D | Delete Word After Cursor | Cuts the next word. |
| Ctrl + U | Delete to Line Start | Cuts everything before the cursor — fastest way to scrap a mistyped command. |
| Ctrl + K | Delete to Line End | Cuts everything after the cursor. |
| Ctrl + Y | Yank (Paste) | Pastes the most recently cut text back. |
| Ctrl + T | Transpose Characters | Swaps the two characters around the cursor — fixes “sl” for “ls”. |
| Ctrl + L | Clear Screen | Clears the terminal, keeping the current line. |
| Ctrl + _ | Undo | Undoes the last editing change (also Ctrl + X, Ctrl + U). |
| Shortcut | Action | Description |
|---|---|---|
| Ctrl + R | Reverse Search | Incremental search backward through history — keep pressing to go further back. |
| Ctrl + S | Forward Search | Searches forward (needs `stty -ixon` in many terminals). |
| Ctrl + P | Previous Command | Same as Up arrow. |
| Ctrl + N | Next Command | Same as Down arrow. |
| !! | Repeat Last Command | Classic use: `sudo !!` after a permissions error. |
| !$ | Last Argument | Expands to the final argument of the previous command. |
Browse shortcuts for 269 platforms
Explore AllA bash cheat sheet really covers two different things. The command tables below are vocabulary — ls, grep, ps — but the Line Editing and History sections are true keyboard shortcuts, provided by the readline library that bash uses for input. They work identically in anything readline-powered (psql, python, mysql), so learning them once upgrades every REPL you touch. To see your own live bindings, run bind -p.
Readline's defaults descend from Emacs: Ctrl + A/E jump to line start and end, Alt + B/F hop by word, and the deletion keys cut into a kill ring you can paste back from with Ctrl + Y. The workhorse combo: mistyped a long command's beginning? Ctrl + U wipes to the start; changed your mind? Ctrl + Y brings it back. Ctrl + T swaps the two characters at the cursor — the instant fix for sl. Prefer vi keys? set -o vi switches the whole editing model.
Arrow-key archaeology is the slow way. Ctrl + R starts an incremental reverse search — type any fragment of a past command and press Ctrl + R again to walk further back through matches. The expansion words are just as fast: !! reruns the last command (the canonical sudo !! after a permission error), and !$ reuses its last argument — mkdir deep/path then cd !$. One trap: Ctrl + S searches forward but many terminals treat it as flow-control freeze; stty -ixon frees it (and Ctrl + Q unfreezes).
Incremental reverse history search: start typing any part of a previous command and readline finds it; press Ctrl+R again to step to older matches, Enter to run, Esc to edit first.
Ctrl+U deletes from the cursor to the start of the line (with the cursor at the end, that's everything). The cut text goes to the kill ring — Ctrl+Y pastes it back.
That's XON/XOFF flow control at the terminal level. Press Ctrl+Q to unfreeze, and add `stty -ixon` to your shell profile to reclaim Ctrl+S for forward history search.
Yes — they're readline defaults, so psql, python's REPL, mysql, and most interactive CLIs honor the same keys. That's why Ctrl+A/E/R feel universal on Linux.
!! expands to the previous command, so after a “permission denied” you type sudo !! to rerun it with privileges instead of retyping.
Run `set -o vi` (or put it in ~/.bashrc). Esc then h/j/k/l, w/b, and the rest of vi's editing grammar replace the Emacs-style defaults on this page.
Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"