If you work in the command line on Bash a lot you’ll probably find that you often repeat commands. Often you need to run similar commands, but change something like a path, for example. Below are 5 very basic and simple things you should get into the habit of using as they just might make your life simpler. They work wonders for me :)
1. Search the command history:
$ ctrl+r (reverse-i-search)`ls': ls - l /opt/local/var/db/mysql5
This is by far the handiest tip. On the command line, press the Control button and R. This will activate a reverse interactive search. start typing something that was in the command and it will return the last command with the text in it. If it is not this particular command you were looking for, press Control+R again and it will return the next command. Keep hitting Control+R until you find the command you were looking for and hit enter to run the command. It beats retyping commands or pressing the up arrow until you get the command. :)
2. Edit the previous command
$ fc
Running the fc command opens your default system editor (VIM in most cases) and allow you to edit the command. After your changes when you exit VIM your edited command will execute. This is handy if you were running a complex long command but made a mistake and need to edit some things somewhere in the middle of the complex command. Handy if you remember you can do that.
3. Run the last command of a certain type
$ !ssh ssh -l stii stii.co.za
If you’ve ran a bunch of commands and cannot remember exactly when last you ran a certain command, but you know you want to run the last ssh command, use the !ssh to run the last ssh command you’ve executed. This will save you time again on paging up through your history to find that command.
4. Run the last command of a certain type, replacing some values
$ !ssh:s/stii.co.za/afrigator.com ssh -l stii afrigator.com
Same as the previous command except it will replace the domain name stii.co.za with the domain afrigator.com. Very, very handy one for running repetitive commands with different arguments. It sure as hell beats finding the command, backspacing the argument you want to change and typing in the correct value!
5. Swop two characters quickly
If you have twiddle fingers or cronic dyslexia like some of us, then this one’s a gem. ;) Lets say you typed a command and swapped two characters around:
$ cd /home/afrigtaor
Instead on moving your cursor to the a, backspacing twice and retyping the a and t in the correct order, all you need to do is to move your cursor to the a and press Control+t and it will swop the t and the a around fixing your typo. Although this one is a bit of a useless one, if you do swap characters often, it might be handy to know of this trick ;)
These tips are very basic and would probably not be news for most experienced Bash aficionados. I find these very handy and use them often on a daily basis, so maybe it could be handy to someone else. If you have a set of your own favorite tricks, please do let me know as I love learning and improving! Happy Bashing!
Welcome back! You should subscribe to my RSS feed here.
You should follow me on Twitter here
You should follow me on Gatorpeeps here.


Bash (a.k.a. Bourne Again SHell) is one of the best tools you’ll ever come across on Linux, Unix or OSX. You can do virtually anything with it! It is said that 



