Command Line shortcuts

no quiz required


You can find all my latest posts on medium.

Here are some handy tips and tricks you can perform inside the bash terminal to help you speed up productivity

Retrieve and run an earlier command

This is done in few ways:

  • By pressing up and down to scroll through previously run commands
  • Hold down ctrl+r, this will bring up the “reverse-i-search” prompt. You can then type a part of the command, and this prompt will automatically return the most recent match from your command history, You can scroll back to earlier matches by doing ctrl+r repeatedly
  • Using the “!{command}” notation. this will run the last matching command what ever that was. This is particurly handy for running long unwieldy commands, e.g. “!scp”
  • Use history command – this will output a list of your previously run commands. You can then run a command by copy+pasting one of your historical commands. Or you can run !{history number}

Command editing shortcuts

While on the command line you can do the following:

  • Ctrl+a (or the home key ) : jump to the line’s beginning
  • Ctrl+e (or the end key) : Jump to end of line
  • Ctrl+u : delete everything from start of line to cursor
  • Ctrl+k : delete everything from the cursor to end up line
  • Ctrl+LeftArrow : go to the next word on the command line
  • Ctrl+RightArrow : go to the previous word on the command line
  • Press tab key twice midway through writing a command, this will try to autocomplete your command.