Essential Bash Commands

I am constantly amazed when I search for bash commands and get page after page of terminal shortcuts or linux commands like cat, ls, and set.

Having said the above, my list of essential bash commands:

Description Command Note
cd to previous directory cd -  
execute previous command !! you can also add to the previous command (e.g. !!morestuff)
execute previous command from history !n where “n” is the command number from your command history (use 'history' see previous commands)
execute previous back command !-n execute command “n” lines back (e.g. '3' commands back)
previous command argument (single) !$ use the previous commands last argument (e.g. mkdir ~/tmp; cd !$)
previous command argument (all) !* use all previous command arguments (e.g. echo “hi” “bye”; echo !*)
list command history history shows a list of previous commands, useful to grep this list (also use with ! to execute a previous command
and list command1 && command2 command2 is executed if command1 returns a zero exit status
or list command1 || command2 command2 is executed if comand1 returns a non-zero exit status
command substitution $(command) or `command` output of command is substituted for command
     
     
     

 

More Info