Bash / Terminal

Bash & terminal shortcuts.

Edit the command line at speed — move and delete by word, search history, and control commands. Works in bash & zsh.

Move the cursor
Jump to start of lineCtrl+A
Jump to end of lineCtrl+E
Back one wordAlt+B
Forward one wordAlt+F
Back one characterCtrl+B
Forward one characterCtrl+F
Edit the line
Cut to start of lineCtrl+U
Cut to end of lineCtrl+K
Delete word before cursorCtrl+W
Delete word after cursorAlt+D
Paste (yank) cut textCtrl+Y
Undo last editCtrl+_
Transpose two charactersCtrl+T
Clear line before cursorCtrl+U
History
Reverse search historyCtrl+R
Previous commandCtrl+P
Next commandCtrl+N
Run last command!+!
Last argument of last command!+$
Cancel a reverse searchCtrl+G
Control & screen
AutocompleteTab
Cancel current commandCtrl+C
End of input / exit shellCtrl+D
Clear the screenCtrl+L
Suspend to backgroundCtrl+Z
These are the default (Emacs-mode) readline keys used by bash and zsh, so they work the same on macOS, Linux and WSL — and inside most terminal apps.

Your shell already has superpowers

Most people retype or arrow through long commands one character at a time, not realising the shell has rich line-editing built in. The two to learn first are Ctrl + A and Ctrl + E, which jump to the start and end of the line — far faster than holding the arrow keys. Add Alt + B and Alt + F to hop whole words, and you can reach any part of a command instantly.

History is the real time-saver

The single most useful shortcut here is Ctrl + R: start typing any part of a command you ran before and the shell finds it, so you almost never need to retype long commands. Press Ctrl + R again to step further back. Combined with Ctrl + W (delete the word behind the cursor) and Ctrl + U (clear the line), you can recall a past command and tweak it in a couple of keystrokes. These readline keys work identically in bash and zsh, so the habits carry across machines. Pair them with the Linux commands and the tmux cheatsheet for a complete terminal toolkit.

FAQ

Do these work in zsh and on macOS too?
Yes. They're standard readline (Emacs-mode) bindings used by both bash and zsh, so they behave the same on macOS, Linux and Windows WSL.
What is Ctrl + R in the terminal?
Ctrl + R starts a reverse history search — type part of a previous command and the shell finds it. Press Ctrl + R again to find older matches, then Enter to run it.

More cheatsheets