A word from our sponsors

Keyboard Shortcuts

A collection of useful bash keyboard shortcuts.

Cursor Movement

Key Combination Description Example Necessary Configuration
CTRL+b Move the cursor one character backward.
CTRL+f Move the cursor one character forward.
ALT+b Move the cursor one word backward.
ALT+f Move the cursor one word forward.
CTRL+a Move the cursor to the beginning of the line.
CTRL+e Move the cursor to the end of the line.
CTRL+l Clear the screen.

Editing

Key Combination Description Example Necessary Configuration
ALT+. Insert the argument of the previous command at the current position
touch /tmp/test.txt
ls -al 

followed by: ALT+. results in

ls -al /tmp/test.txt
CTRL+d Cut one character from the current cursor position.
CTRL+w or ALT+BACKSPACE Cut one word from before the current cursor position.
CTRL+u or CTRL+x BACKSPACE Cut the characters from before the current cursor position to the beginning of the line.
CTRL+k Cut everything from the current cursor position to the end of the line.
ALT+d Cut one word from the current cursor position to the next word boundary.
ALT+\ Cut all tabs and spaces around the current cursor position.
CTRL+y Insert the characters last cut at the current cursor position.
CTRL+t Transpose the character at the current cursor position with the one before.
ALT+t Transpose the word at the current cursor position with the one before.
ALT+u Transform the word starting at the current cursor position into all upper case characters.
ALT+l Transform the word starting at the current cursor position into all lower case characters.
ALT+c Capitalize the word starting at the current cursor position.

History

Key Combination Description Example Necessary Configuration
CTRL+p or Previous command in the command history.
CTRL+n or Next command in the command history.
CTRL+r Reverse search the command history.
CTRL+s Forward search the command history.
ALT+< Jump to the beginning of the command history.
ALT+> Jump to the end of the command history.

Macros

Key Combination Description Example Necessary Configuration
CTRL+( Start macro recording.
CTRL+) Stop macro recording.
CTRL+e Execute the last recorded macro.

Misc

Key Combination Description Example Necessary Configuration
CTRL+x CTRL+r Reread the inputrc configuration file.
CTRL+_ Undo changes to the line.
ALT+& Expand the tilde (~) sign in the current line.
CTRL+@ Set a mark at the current cursor position.
CTRL+x CTRL+x Switch from the current cursor position to the one where last mark was set.
CTRL+] char From the current cursor position forward search for char.
CTRL+ALT+] char From the current cursor position backward search for char.
ALT+# Insert a comment (#) sign at the beginning of the current line.
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website. More information about cookies