Skip to content

Useful Bash shortcuts

Michael Watts edited this page Nov 18, 2016 · 1 revision

Movement

Shortcut Action
Ctrl+ a Move to the start of the line
Ctrl + e Move to the end of the line
Ctrl + b Move back one character
Alt + b Move back one word
Ctrl + f Move forward one character
Alt + f Move forward one word
Ctrl + ] + x Move the cursor forward to next occurance of x
Alt + Ctrl + ] + x Move the cursor backward to the next occurance of x

Line Modification

Shortcut Action
Ctrl-u Delete from the cursor to the beginning of the line
Ctrl-k Delete from the cursor to the end of the line
Esc Backspace Delete back a word
Alt-d Delete forward a word
Alt-r Undo all changes to the line
Ctrl-y Paste any text deleted with previous shortcuts
Ctrl-e Esc-t Swap order of the last two arguments

History Utilisation

Shortcut Action
Ctrl-x Ctrl-u Undo the last change to the line
Ctrl-r Incremental reverse search of history
Alt-p Non-incremental reverse search of history
Ctrl-L Clear the screen (doesn't wipe current line)
!! Execute last command in history
!abc Execute last command in history beginning with abc
!n Execute nth command in history
!$ Last argument of previous command
!^ First argument of previous command
^abc^xyz Replace first occurance of abc with xyz in previous command and execute it
Alt-. Paste last word from previous command after cursor position (repeat to cycle through previous commands)

SSH

2 Best practices when logging in remotely to linux machine

WARGAMES

Clone this wiki locally