>

Shortcut Description

Cursor Movement

Ctrl + a Move cursor to start of the line
Ctrl + e Move cursor to end of the line
Ctrl + b Move cursor back one character
Ctrl + f Move cursor back one character
Alt/Esc + b Move cursor back one word
Alt + f Move cursor forward one word
Ctrl + xx Toggle between the end of line and current cursor position
Ctrl + ] c Move cursor to the position of charactor c on right
Esc + Ctrl + ] c Move cursor to the position of charactor c on left
Ctrl + r c Move cursor to the position of charactor c on left
Ctrl + s Search on current line and move cursor to the right found charactor(need to execute stty -ixon to release XON/XOFF swtich)
Ctrl + o Execute the command found via Ctrl+r or Ctrl+s

Edit

Ctrl + l Clears the Screen, similar to the clear command
Ctrl + u Cut everything before the cursor position
Ctrl + k Cut everything after the cursor position to the end of line
Ctrl + d Delete character under the cursor
Ctrl + h Delete character before the cursor (Backspace)
Ctrl + w Cut the current word before the cursor
Alt + d Cut the current word after the cursor
Ctrl + y Paste the previous cut text
Alt + y Paste the second latest cut text
Alt + Ctrl + y Paste the first argument of the previous command
Alt + ./_ Paste the last argument of the previous command
Ctrl + p Paste previous command, ↑
Ctrl + n Paste next command, ↓
Alt + t Swap current word with previous
Ctrl + t Swap the last two characters before the cursor (typo).
Esc + t Swap the last two words before the cursor.
Alt + \ Delete all blank space before the current cursor

Undo && Redo

Ctrl + xu Undo (don’t release ctrl when press x and u)
Ctrl + shift + - Undo
Ctrl + / Undo

History

Ctrl + p Paste previous command
Ctrl + n Paste next command
Alt + n Move to the next line
Ctrl + r Search history
Ctrl + g Abort search (and restores original line)
Ctrl + j End search
Alt + r Restores all changes made to line

Completion

Tab Auto-complete a name
Alt + ? List all possible completions
Alt + * Insert all possible completions
Ctrl + x @ Show possible hostname completions

Other

Ctrl + c Kill whatever you are running
Ctrl + d Log out of the current session, same as exit
Ctrl + z Puts current process into a suspended background process(use fg to restores)
Ctrl + s Hide command input (use Ctrl + q to restore)s

Special commands

~ Moves to the user’s home directory.
!! Repeats last command
!abc Run last command starting with abc
!abc.p Print last command starting with abc
!$ Last argument of the previous command
ALT + ./_ Last argument of the previous command
^abc^123 Run previous command, replacing abc with 123
tput reset Resets the terminal if terminal screen is not displaying correctly.
shutdown -h now Remotely or locally shuts the system down.
fg [#] brings background jobs foreground.
ps -p $$ print the current session shell

Emacs mode vs Vi Mode

All the above assume that bash is running in the default Emacs setting, if you prefer this can be switched to Vi shortcuts instead.

Set Vi Mode in bash:

$ set -o vi

Set Emacs Mode in bash:

$ set -o emacs
Extra

bind -P List all binding shortcuts

Ubuntu

CTRL + ALT + T bash command line

Reference

https://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/