Useful Bash shortcuts

Miscellaneous

!! Re-execute previous command.
!27 Execute command 27 in the history (look it up with: history | tail)
Ctrl + R Reverse search in history (type Ctrl + R to search incrementally)
Ctrl + L Clear the terminal. The same as typing clear
Ctrl + M Enter/return. Useful if inside a long command.
Ctrl + S/Q Freeze terminal/Restore frozen terminal

Move and View Commands

Ctrl + A Go to begin of line (mnemonic: “Anfang” (DE))
Ctrl + E Go to end of line (mnemonic: “end”)
Ctrl + F or Arrow Right Forward one character.
Ctrl + B or Arrow Left Backward one character.
Alt + F or Ctrl + Arrow Right Forward one word.
Alt + B or Ctrl + Arrow Left Backward one word.
Shift + Page Up/Page Down Scroll view up/down one page

Edit Commands

Ctrl + K Delete from cursor to end of line
Ctrl + U Delete from cursor to begin of line
Ctrl + W Delete word left of cursor
Alt + D Delete word right of cursor
Ctrl + D Delete character under cursor or exit bash if line is empty.

Leave a Reply