This page looks best with JavaScript enabled

Essential Bash Commands

 ·  ☕ 1 min read

Background

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.

Details

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

DescriptionCommandNote
cd to previous directorycd -
execute previous command!!you can also add to the previous command (e.g. !!morestuff)
execute previous command from history!nwhere “n” is the command number from your command history (use 'history' see previous commands)
execute previous back command!-nexecute 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 historyhistoryshows a list of previous commands, useful to grep this list (also use with ! to execute a previous command
and listcommand1 && command2command2 is executed if command1 returns a zero exit status
or listcommand1 || command2command2 is executed if comand1 returns a non-zero exit status
command substitution$(command) or `command`output of command is substituted for command

Notes

Share on

drad
WRITTEN BY
drad
Sr. Consultant