Mikael Manukyan

Minimum list of useful bash shortcuts

December 08, 2019 · 3 mins to read

I often end up googling “bash shortcuts” and every result lists a huge list of shortcuts available in bash, some of them are overridden by other utils, like fzf or by your terminal itself, some of them are not that helpful. I compiled the minimal list of shortcuts and commands which can increase your productivity in bash.

Note: MacOS iTerm 2 users must turn on meta key - https://coderwall.com/p/_lmivq

A good visual cheatsheat of shortucts taken from Clement Chastagnol’s article:

bash cli cheatsheat

Also, in the description I’ll say how I memorize the shortcuts.

Shortcut Description Memorization
Navigation
Ctrl + a Go to the beginning of the line. a is the 1st letter of alphabet, hence the beginning of the line.
Ctrl + e Go to the end of the line. end.
Alt + b Move cursor back one word, will jump to the current word’s first character or if already there to the previous word’s first character. back.
Alt + f Move cursor forward one word, will jump to the next word’s first character. forward.
Ctrl + x x Toggle between the current cursor position and the beginning of the line. Very handy when you want fix typo in the program name and come back.
Edit
Ctrl + _ Undo. just remember it’s Ctrl + Shift + -
Ctrl + u Delete the line before the cursor.
Ctrl + k Delete the line after the cursor.
Ctrl + w Delete the word before the cursor. word.
Ctrl + y Paste the last deleted item. yank.
Ctrl + x, Ctrl + e Edit the current command in your $EDITOR.
Processes
Ctrl + l Clear screen cls (hello BASIC)
Ctrl + z Move current process to background. Use fg to bring back. zZzzz (sleep)
Ctrl + c Send SIGINT to the current process.
Ctrl + d Exit the current shell (also works in SSH, so need to type exit). down
Enter, ~, . Exit stalled SSH session
History
Ctrl + r Reverse search of bash history. reverse

All other shortcuts can be found in man bash. To understand the syntax read Readline Notation section first and then move on to Commands for Moving.

Another helpful cheatsheat with Bash shortcuts and features can be found at fliptheweb/bash-shortcuts-cheat-sheet.

  • bash
  • linux
  • zsh
  • shortcuts

  • Previous Post

  • Next Post