Bash Keyboard Shortcuts: The Complete Cheat Sheet
Bash keyboard shortcuts are key combinations powered by the GNU Readline library that let you move the cursor, edit a command, search your history, and control running processes without ever touching the mouse or arrow keys. Learning even a dozen of them will noticeably speed up how fast you work in the terminal.
This guide lists every essential shortcut, explains exactly what each one does, and shows you how to use, customize, and troubleshoot them on Linux, macOS, and WSL. A free printable PDF is at the bottom.
What Are Bash Shortcuts?
Bash is the default shell on most Linux distributions and was the default on macOS until Catalina. Every time you type at the prompt, you’re actually using Readline, which intercepts key combinations and turns them into editing actions jump to the start of the line, delete a word, recall an old command, and so on.
These shortcuts fall into five practical groups:
- Navigation: move the cursor around the line
- Editing: change, cut, paste, and transform text
- History: recall and search previous commands
- Process control: manage what’s currently running
- History expansion (!): reuse parts of past commands
Navigation Shortcuts
Use these to move the cursor without holding down the arrow keys. Ctrl + A and Ctrl + E are the two most useful shortcuts in all of Bash learn these first.
| Shortcut | Action |
| Ctrl + A | Move to the beginning of the line |
| Ctrl + E | Move to the end of the line |
| Ctrl + F | Move forward one character |
| Ctrl + B | Move backward one character |
| Alt + F | Move forward one word |
| Alt + B | Move backward one word |
| Ctrl + XX | Toggle between the start of the line and the current cursor position |
Editing Shortcuts
These let you cut, paste, delete, and transform text on the current line. Bash keeps cut text in a kill ring, so anything you cut with Ctrl + W, Ctrl + K, or Ctrl + U can be pasted back with Ctrl + Y.
| Shortcut | Action |
| Ctrl + W | Cut the word before the cursor |
| Ctrl + K | Cut everything after the cursor to the end of the line |
| Ctrl + U | Cut everything before the cursor to the start of the line |
| Ctrl + Y | Paste (yank) the last text you cut |
| Alt + D | Delete the word after the cursor |
| Alt + Backspace | Delete the word before the cursor |
| Ctrl + D | Delete the character under the cursor |
| Ctrl + H | Delete the character before the cursor (same as Backspace) |
| Ctrl + T | Swap (transpose) the last two characters before the cursor |
| Alt + T | Swap the current word with the previous one |
| Alt + U | Uppercase from the cursor to the end of the word |
| Alt + L | Lowercase from the cursor to the end of the word |
| Alt + C | Capitalize the character under the cursor and move to the end of the word |
| Alt + R | Revert all changes to a line you pulled from history |
| Ctrl + _ | Undo the last edit (repeatable) |
History & Reverse Search
This is where shortcuts save the most time. Instead of pressing the Up arrow twenty times, search your history directly.
| Shortcut | Action |
| Ctrl + R | Reverse-search your command history as you type |
| Ctrl + S | Search history forward (see the note below) |
| Ctrl + P | Previous command (same as Up arrow) |
| Ctrl + N | Next command (same as Down arrow) |
| Ctrl + O | Run the command found via search, then load the next one |
| Ctrl + G | Abort the search and return to a clean prompt |
| Ctrl + J | Accept the found command without running it |
| Alt + . | Insert the last argument of the previous command |
How to use Ctrl + R (reverse search)
- Press Ctrl + R.
- Start typing any part of a past command (e.g. ssh).
- Bash shows the most recent match. Press Ctrl + R again to step further back through matches.
- Press Enter to run it, → / Ctrl + E to edit it first, or Ctrl + G to cancel.
About Ctrl + S: In many terminals Ctrl + S freezes the screen (XOFF flow control) instead of searching forward. If it locks up your terminal, press Ctrl + Q to unfreeze. To free up Ctrl + S for forward search, add stty -ixon to your ~/.bashrc.
Alt + . is a hidden gem: After running mkdir /very/long/path/name, type cd then press Alt + . to instantly paste /very/long/path/name.
Process Control Shortcuts
These manage the program currently running in your terminal.
| Shortcut | Action |
| Ctrl + C | Interrupt (kill) the current process — sends SIGINT |
| Ctrl + Z | Suspend the current process — sends SIGTSTP (resume with fg or bg) |
| Ctrl + D | Send EOF; on an empty prompt, exits the shell |
| Ctrl + L | Clear the screen (same as the clear command) |
| Ctrl + S | Pause output to the screen (XOFF) |
| Ctrl + Q | Resume paused output (XON) |
History Expansion with ! (Bang)
The ! character lets you reuse past commands and their arguments. These aren’t keystrokes you type them as part of a command.
| Syntax | What it does | Example |
| !! | Repeat the previous command | sudo !! reruns your last command with sudo |
| !abc | Run the most recent command starting with abc | !ssh reruns your last ssh … |
| !abc:p | Print (don’t run) the last command starting with abc | Lets you review before executing |
| !$\vert{} The last argument of the previous command \vert{} mkdir test && cd !$ | ||
| !* | All arguments of the previous command | |
| !n | Run command number n from history | !42 |
| ^old^new | Rerun the last command, replacing old with new | ^typo^fixed |
Tip: Run history to see numbered past commands, then use !n to rerun any of them.
Download the Bash Shortcuts PDF
Download the complete Bash Shortcuts cheat sheet (PDF) print it and keep it next to your keyboard.
Frequently Asked Questions
How do I see all Bash keyboard shortcuts on my system?
Run bind -P to list every active Readline binding, or bind -p for a remappable format.
Why don’t my Bash shortcuts work over SSH?
The remote session uses its own terminal and Readline settings. Differences in TERM, tmux/screen, or stty flow control can change how keys behave. Local ~/.inputrc customizations also don’t travel with you over SSH.
What’s the difference between emacs mode and vi mode?
Emacs mode (the default) uses direct key combinations like Ctrl + A. Vi mode is modal — you press Esc to enter command mode and use Vim-style keys. Switch with set -o vi or set -o emacs.
How do I use Ctrl + R reverse search?
Press Ctrl + R, type part of a past command, press Ctrl + R again to cycle older matches, then Enter to run or Ctrl + G to cancel.
Do Bash shortcuts work on macOS?
Yes, but macOS defaults to zsh and treats the Option key specially. Enable “Use Option as Meta key” in your terminal settings so Alt-based shortcuts work.
How do I create my own Bash shortcut?
Add a binding to ~/.inputrc (for editing actions) or use bind ‘”\C-g”:”git status\n”‘ in ~/.bashrc (to bind a key to a command).
Final Thoughts
Mastering Bash shortcuts is one of the highest-return habits you can build as a developer or sysadmin every keystroke you save compounds across thousands of commands. Start with the two that matter most, Ctrl + A and Ctrl + E, then add Ctrl + R for history search and Alt + . for reusing your last argument. Within a week they’ll feel automatic.
Because every shortcut here is powered by GNU Readline, the same muscle memory carries over to other Readline-based tools like the Python REPL, psql, and many other command-line programs. Bookmark this page, grab the PDF, and run bind -P whenever you want to see every binding your shell supports.
READ NEXT:





