Keyboard Shortcuts

Moving the cursor:

  Ctrl + A   Go to the beginning of the line you are currently typing on
  Ctrl + E   Go to the end of the line you are currently typing on 
  alt-b      Move cursor back one word
alt-f Move cursor forward one word Ctrl + R Search through previously used commands TAB Tab completion for file/directory names

For example, to move to a directory 'sample1'; Type cd sam ; then press TAB and ENTER.
type just enough characters to uniquely identify the directory you wish to open.

Editing:

 Ctrl + L   Clear the Screen, similar to the clear command
 Ctrl + U   Cut/delete the line before the cursor position.
 Ctrl + H   Backspace
 Ctrl + W   Cut/delete the Word before the cursor (the last word)
 Ctrl + K   Cut/delete the line after the cursor
 Ctrl + T   Swap the last two characters before the cursor
 Esc  + T   Swap the last two words before the cursor 
 ctrl + y	 Paste the last thing to be cut
ctrl + _ Undo

Process control:

 Ctrl + C Kill whatever you are running
 Ctrl + D Exit the current shell
 Ctrl + Z Put whatever you are running into a background process. 

After pressing Ctrl-Z the process will not continue to run. To put the last suspended job into the background run bg without a job number:

Emacs mode vs Vi Mode

All the above assume that bash is running in the default Emacs setting, if you prefer this can be switched to Vi shortcuts instead.

Set Vi Mode in bash:

$ set -o vi 

Set Emacs Mode in bash:

$ set -o emacs 

Related commands:

jobs - List foreground and background jobs.
fg - Bring a command to the foreground.
~./.bash_history - Text file with command history



Back to the Top

Simon Sheppard
SS64.com