Bash Shortcuts

January 14, 2014

I’ve often wanted these in one place where I could reach them quickly. I started with the base list I found in an old post on Alan Skorkin’s site, and then just reordered them roughly in importance to the way I use the shell.

Command Recall

  • Up Arrow or Ctrl+p  – previous command in history 
  • Down Arrow or Ctrl+n  – next command in history
  • Ctrl+r – search history backwards
  • Ctrl+g – escape from history search mode
  • Alt+. – use the last word of the previous command

Editing

  • Ctrl+a – go to start of line
  • Ctrl+e – go to end of line
  • Ctrl+k – delete from cursor to end of line
  • Ctrl+u – delete from cursor to start of line
  • Ctrl+w – delete backward one word
  • Ctrl+y – paste cut word or text
  • Ctrl+xx – move between start of line and current position
  • Ctrl+f – move forward one character
  • Ctrl+b – move backward one character
  • Ctrl+d – delete current character
  • Ctrl+h – delete previous character
  • Ctrl+t – swap current character with the previous one
  • Alt+b – move backward one word
  • Alt+f – move forward one word
  • Alt+d – delete to end of word
  • Alt+c – capitalize to end of word
  • Alt+u – make uppercase to end of word
  • Alt+l – make lowercase to end of word
  • Alt+t – swap current word with previous

Miscellaneous

  • Ctrl+s – pause output to the screen
  • Ctrl+q – resume output to the screen 
  • Ctrl+c – terminate a running command
  • Ctrl+l – clear screen
  • Ctrl+d – log out of the session
  • Ctrl+z – suspend/stop a running command

Previous post:

Next post: