There are many useful Bash readline shortcuts that can speed up your command-line workflow. Here are some of the most useful ones I use, grouped by category:
Editing Commands
Ctrl + w
→ Delete the word before the cursorCtrl + u
→ Delete everything before the cursorCtrl + k
→ Delete everything after the cursorCtrl + y
→ Paste (yank) the last deleted textAlt + d
→ Delete the word after the cursorAlt + Backspace
→ Delete the word before the cursor (likeCtrl + w
, but stops at punctuation)Ctrl + l
→ Clear the terminal screen (likeclear
)
Cursor Movement
Ctrl + a
→ Move cursor to the beginning of the lineCtrl + e
→ Move cursor to the end of the lineAlt + f
→ Move forward one wordAlt + b
→ Move backward one wordCtrl + f
→ Move forward one characterCtrl + b
→ Move backward one character
History & Navigation
Ctrl + r
→ Search command history (type to search, pressCtrl + r
again for next match)Ctrl + g
→ Cancel history searchUp/Down Arrow
→ Browse command historyCtrl + p
→ Previous command (same as Up Arrow)Ctrl + n
→ Next command (same as Down Arrow)!!
→ Re-run the last command!<n>
→ Run command number<n>
from history (history
command lists them)!<prefix>
→ Run the most recent command that starts with<prefix>
Process Management
Ctrl + c
→ Cancel the current commandCtrl + z
→ Suspend (pause) the current process (can be resumed withfg
)fg
→ Resume a suspended process in the foregroundbg
→ Resume a suspended process in the background
Miscellaneous
Ctrl + x Ctrl + e
→ Open the current command in your default editor ($EDITOR
)Ctrl + s
→ Freeze terminal output (resume withCtrl + q
)Ctrl + d
→ Send EOF (End-of-File) signal, often used to exit a terminal session