March 18, 2011

Several useful linux commands

  • $ sudo !! - run the previous command with superuser privileges.
  • $ cd !$ - the “!$” is a shortcut for the argument used in the last command. So if you create a directory in one like using mkdir, you can type this command to change to that directory without needing to type out the whole directory name. Handy!
  • $ !cd - re-run the most recent command starting with “cd”.
  • $ ^save^dave^ - re-run the previous command, replacing the first instance of “save” with “dave”.
  • $ CTRL-r - search backwards through your commands (great for re-running a recent command).