All Shortcuts

Bash / Shell Shortcuts & Commands — Complete Cheat Sheet (32)

Complete Bash and Shell commands cheat sheet for Linux system administration. Covers file operations, text processing, system monitoring, networking, and pipe operations.

Related Shortcut Pages

VS Code Jupyter Notebook PyCharm Xcode Neovim / Vim WebStorm

Search all Bash / Shell shortcuts interactively

Interactive Shortcut Finder

All Bash / Shell Shortcuts

Files & Directories

ShortcutActionDescription
ls -laDetailed listShow detailed file list including hidden files.
cd [path]Change directoryNavigate to the specified directory.
pwdCurrent pathPrint current working directory.
mkdir -p [path]Create directoryCreate directories including parents.
cp -r [src] [dst]CopyCopy files or directories.
mv [src] [dst]Move/RenameMove or rename files.
rm -rf [path]Force deleteForce delete files or directories.
find . -name [pattern]Find filesSearch for files by name pattern.
chmod +x [file]Make executableAdd execute permission to a file.
chown [user]:[group] [file]Change ownerChange file ownership.

Text Processing

ShortcutActionDescription
cat [file]Print filePrint file contents.
grep [pattern] [file]Search textSearch for patterns in files.
head -n 20 [file]First N linesShow first 20 lines of a file.
tail -f [file]Follow fileFollow the end of a file in real time.
wc -l [file]Count linesCount lines in a file.
sort [file]SortSort file contents.
sed 's/old/new/g' [file]Find & replaceFind and replace text in files.
awk '{print $1}' [file]Extract fieldsExtract specific fields from files.

System & Processes

ShortcutActionDescription
ps auxList processesShow all running processes.
topSystem monitorShow real-time system resource usage.
kill -9 [PID]Force killForce kill a process.
df -hDisk usageShow disk usage in human-readable format.
du -sh [path]Directory sizeShow total directory size.
free -hMemory usageShow memory usage.
curl [URL]HTTP requestSend an HTTP request to a URL.
ssh [user]@[host]SSH connectConnect to a remote server via SSH.
scp [file] [user]@[host]:[path]Remote copyCopy files remotely via SSH.

Pipes & Redirects

ShortcutActionDescription
[cmd] | [cmd]PipePass output of one command as input to another.
[cmd] > [file]Redirect outputSave command output to file (overwrite).
[cmd] >> [file]Append outputAppend command output to file.
[cmd] 2>&1Redirect stderrMerge error output with standard output.
xargsPass argumentsConvert stdin to arguments for a command.

Line Editing (readline)

ShortcutActionDescription
Ctrl + AStart of LineMoves the cursor to the beginning of the command line.
Ctrl + EEnd of LineMoves the cursor to the end of the line.
Ctrl + BBack One CharacterSame as Left arrow.
Ctrl + FForward One CharacterSame as Right arrow.
Alt + BBack One WordJumps the cursor back a word.
Alt + FForward One WordJumps the cursor forward a word.
Ctrl + WDelete Word Before CursorCuts the previous word into the kill ring.
Alt + DDelete Word After CursorCuts the next word.
Ctrl + UDelete to Line StartCuts everything before the cursor — fastest way to scrap a mistyped command.
Ctrl + KDelete to Line EndCuts everything after the cursor.
Ctrl + YYank (Paste)Pastes the most recently cut text back.
Ctrl + TTranspose CharactersSwaps the two characters around the cursor — fixes “sl” for “ls”.
Ctrl + LClear ScreenClears the terminal, keeping the current line.
Ctrl + _UndoUndoes the last editing change (also Ctrl + X, Ctrl + U).

History

ShortcutActionDescription
Ctrl + RReverse SearchIncremental search backward through history — keep pressing to go further back.
Ctrl + SForward SearchSearches forward (needs `stty -ixon` in many terminals).
Ctrl + PPrevious CommandSame as Up arrow.
Ctrl + NNext CommandSame as Down arrow.
!!Repeat Last CommandClassic use: `sudo !!` after a permissions error.
!$Last ArgumentExpands to the final argument of the previous command.
📜 Source: GNU Bash Reference Manual. Commands are standard GNU/Linux userland; editing and history keys are readline defaults from the GNU Bash Reference Manual, verified live against GNU bash 5.2.21 default bindings (`bind -p`). Checked 2026-08-03.

Browse shortcuts for 269 platforms

Explore All
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

Two kinds of “shortcuts”

A 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.

Emacs-style editing, sixty years on

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.

History is a database, not a scrollback

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).

Frequently asked questions

What does Ctrl+R do in bash?

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.

How do I delete the whole command line in bash quickly?

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.

Why does Ctrl+S freeze my terminal instead of searching?

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.

Do bash editing shortcuts work in other tools?

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.

What is sudo !! and why does everyone use it?

!! expands to the previous command, so after a “permission denied” you type sudo !! to rerun it with privileges instead of retyping.

How do I switch bash to vi-style editing?

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.

🤖 Ask AI about Bash / Shell shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok