Working quickly with some Useful Terminal and Bash Shortcuts

  • HOME
  • >
  • BASH
  • >
  • Working quickly with some Useful Terminal and Bash Shortcuts
Last Updated: 

The other day, one of my friend was doing some stuff on its Mac OSX Term without using any shortcuts. I suggest some of them (which are POSIX, GNU or Shell keys combinations) to him and he answer me : Why don't you post it on shell-tips.com ?!. So, here we are.

Those shortcuts are for VT100 Terminals and Bash shell.

Control Keys combinations** (CTRL+KEY)

  1. ctrl+a : move your cursor to the beginning of the line
  2. ctrl+e : move your cursor to the end of the line
  3. ctrl+k : delete any characters from your cursor to the end of the line
  4. ctrl+u : delete any characters from your cursor to the beginning of the line
  5. ctrl+w : delete previous word
  6. ctrl+t : transpose two previous characters
  7. ctrl+y : yank/recover the last deletion
  8. ctrl+d : delete one character at the cursor position
  9. ctrl+h : delete one character before the cursor
  10. ctrl+f : move forward (or use the right arrow ! 😃
  11. ctrl+b : move backward (or use the left arrow ! 😃
  12. ctrl+r : find character sequence in history (completion mode)
  13. ctrl+g : escape from completion mode
  14. ctrl+v : Literal next (LNEXT)

:point_right> LNEXT interpret the next character as a string. eg : to symbolize a CR+LF you must use the key combination ctrl+v return which will print the special character ^M.

Escape Keys combinations** (ESC+KEY)

  1. esc+d : delete from the cursor position to the end of the word
  2. esc+f : move forward a word
  3. esc+b : move backward a word
  4. esc+t : transpose two adjacent words

Other common keys

  1. Use up/down arrows to move through the bash command history
  2. Use left/right arrows to move on the current line
  3. Use tabulation key (TAB) for auto-complete a command name or a file name
  4. Use exclamation key + command name for repeat last similar command (ex. : !vi will recall the last vi command)
Related bash posts that you may like...
The Complete How To Guide of Bash Functions
Learn how to write shell scripts with bash functions. This guide includes examples and best practices on how to define, call, and debug functions in bash.
How To Create Simple Menu with the Shell Select Loop?
The select loop is not a regular shell loop. It can be used in Bash to generate a simple menu from which a user can select numbered options.
What is the Right Way to do Bash Loops?
Looping over a list of numbers or words is a building block in shell scripts. Learn how to write Bash loops, including for loop, while loop, and until loop.
What is the Best Way to Count Files in a Directory?
Learn how to count the number of files in a directory using the Linux command line ls, find, and a native bash shell solution with globs and arrays.