UNIX Command Line Cheatsheet

Level up your UNIX Kung Fu

Posted by RICK FARMER    Jan 10, 2017

Handy commands

  • ctrl-l : Clear the screen
  • ctrl-a : Go to the beginning of a line
  • ctrl-e : Go to the end of the line
  • ctrl-k : Delete everything to the right
  • ctrl-w : Delete the previous word
  • ESC-b : Go back one word
  • ESC-f : Go forward one word
  • !! : Reuse the last executed command. Great for when you need to rerun a command with sudo, e.g. sudo !!
  • !$ : Contains the last argument of the previous command. Great for saving retyping, e.g. touch README.txt then cat !$
  • history : View previously executed commands
  • !560 : Will re-run the command at line 560 in the history list
  • !echo : Will re-run the last history command that starts with echo
  • ctrl-r : Interactive pick of history commands (enter to run the command or ⌃ g to abandon it)
  • ⌃ from ⌃ to : Search and replace the first occurrence of a command in history and rerun
  • mv readme.{txt,md} : Replace txt with md

Aliases and Functions

Add aliases and functions should be added to /.bash_rc

To activate added aliases use:

. ~/.bash_rc

alias ss="./script/server"
alias tu='top -o cpu' #cpu sorted
alias tm='top -o vsize' # memory