some Shell commands

I tend to forget these so I’m documenting them here for posterity.

1. Moving around quickly

  • ctrl + a – move to beginning of the line
  • ctrl + e – move to end of the line
  • alt + f – move forward
  • alt + b – move backward

2. ctrl + r – Search shell history. Keep using ctrl + r to cycle results. ctrl + g will preserve what you’ve typed in search and exit the search interface.

3. Clear terminal

$ clear
// or ctrl + l

4. Cut and paste

  • ctrl + k – Cut (kill) to end of line
  • ctrl + u – Cut to beginning of line
  • alt + d – Cut word
  • ctrl + w – Cut word backward
  • ctrl + y – Pastes whatever was cut (yank!)

5. Prepend sudo to previoius command:

$ sudo !!

6. alt + . – Insert previous command’s argument

7. Unbork your shell

$ reset

2 comments

  1. My faves include “pushd” and “popd” along with “dirs -v”, all aliased, of course (pu, po, d). Instead of cd’ing to different directories, pushd them onto the stack, popd them off the stack, and “pushd +n” to pull a directory off the stack.

Leave a Reply to Kitt Hodsden Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.