While working with UNIX (Ubuntu/CentOS/MAC) terminals, it is not very convenient to move your cursors back and forth and it makes our overall productivity low. Since these terminals do not support smooth cursor movement up/down and knowing those shortcuts make our productivity high.

The document has the following sections and each talks about specific shortcusts for UNIX(Mac/CentOS/Ubuntu) Terminals:

  • Editing Shortcuts Command
  • Recall Shortcuts Command
  • Control Shortcuts Command
  • Bash Bang Shortcuts Command

Editing Shortcuts Command

Following Shortcuts and commands help you to move your cursors left/right quickly and hence you edit the unix/shell command more easily. Here it goes:

Editing Command Description
CTRL+A
CTRL+E
Go to the start/end of the command line
CTRL+U
CTRL+K
Delete from cursor to the start/end of the command line
CTRL+W
ALT+D
Delete from cursor to start/end of word (whole word if at the boundary)
CTRL+Y Paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
CTRL+XX Move between start of command line and current cursor position (and back again)
ALT+B
ALT+F
Move backward/forward one word (or go to start of word the cursor is currently on)
ALT+C Capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
ALT+U Make uppercase from cursor to end of word
ALT+L Make lowercase from cursor to end of word
ALT+T Swap current word with previous
CTRL+F
CTRL+B
Move forward/backward one character
CTRL+D
CTRL+H
Delete character after/before under cursor
CTRL+T Swap character under cursor with the previous one

Recall Shortcuts Command

Following Shortcuts and commands help you to recall historically executed command so you don’t need to type them again and again. Here it goes:

Recall Command Description
CTRL+R Search the history backwards
CTRL+G Escape from history searching mode
CTRL+P Previous command in history (i.e., walk back through the command history)
CTRL+N Next command in history (i.e., walk forward through the command history)
ALT+. Use the last word of the previous command

Control Shortcuts Command

Following Shortcuts and commands help you to control your terminals. Here it goes:

Control Command Description
CTRL+L Clear the screen
CTRL+S Stops the output to the screen (for long running verbose command)
CTRL+Q Allow output to the screen (if previously stopped using command above)
CTRL+C Terminate the command
CTRL+Z Suspend/stop the command

Bang Bash Shortcuts Command

You may not need them all the time, but still helpful in many cases. Here it goes:

Bang Bash Command Description
C!! Run last command
C!blah Run the most recent command that starts with blah
C!blah:p Print out the command that !blah would run (also adds it as the latest command in the command history
C!$ The last word of the previous command (same as ALT+.)
C!$:p Print out the word that !$ would substitute
!* The previous command except for the first word (e.g., if you type find some_file.txt /, then !* would give you some_file.txt /)
!*:p Print out what !* would substitute