Add these handy bash aliases for efficiency

Jack Wallen
Jul 5, 2010
Updated • Dec 22, 2012

"In the beginning was the command line" is not the just name of a great book by Neil Stephensen (read the text here), but a way of life for many Linux users. The command line is the tool for just about any level user. However, the power user takes the command line to newer and many different heights and does so in many different ways.

One of those ways is with the help of bash aliases. A bash alias is a way to create shortcuts to commands that would normally take a lot of typing or are a challenge to remember. So instead of ssh -v -l jlwallen I could enter just desktop or whatever I want that shortcut to be. In that vein, I am going to offer up some very handy shortcuts for you to add to make your command line usage more efficient.

Where they go

If you open up a terminal and issue the command ls -a |less you should come across a file called ~/.bashrc. This file is very powerful and handles a LOT of tasks. One such task is that of aliases. Within that file you will find the section:

# Alias definintions

This is where you put your user-created aliases...and where we will place the aliases listed below. Once you create the aliases, you will notice they don't work within the same terminal you used to add them with your text editor. You have to fire up a new terminal to make sure they work. Because of this, always leave your original terminal open to make sure the new terminal will still work. I have witnessed a user fubar their bash such that the terminal would no longer open. So use caution when randomly closing your terminals. Now, on the aliases.

Ask before you remove

Admit it, you've accidentally deleted a file that could have been prevented if you had used the -i switch with the rm command. To avoid this common mistake, let's add an alias such that any time the rm command is issued, it is done with the -i switch. This alias would look like:

alias rm="rm -i"

Secure shell

As I mentioned earlier, secure shell'ing to a machine can be a real pain when you do it over and over. Create an alias like so:

alias server1="ssh -v -l USER ADDRESS"

Where USER is the user name you would log in with and ADDRESS is the address of the machine you are remoting into.

Bookmark alias

Here's a fun one. You can open up your browser to a specific bookmark, from the command line with an alias like so:

alias ghacks="chromium-browser"

Of course you would replace chromium-browser with your default browser and the URL with the address you want the browser to open up to.

RPM batch installation

Say you do a lot of batch installations of RPMS. And say you always save your RPM files to ~/RPMS. You can add an alias to quickly install those RPMS like so:

alias brpm="rpm -ivh ~/RPMS/*rpm"

Update/upgrade with apt

Instead of having to issue both command for updating apt and upgrading your installation, combine them into one easy to use alias like so:

alias update="sudo apt-get update ; sudo apt-get upgrade"

You will have to enter your sudo password once and the update/upgrade will take place.

Final thoughts

Bash aliases are only limited to your imagination. After you spend enough time with the command line you will see that these aliases can really make your day to day Linux life much easier.


Previous Post: «
Next Post: «


  1. Anonymous said on July 13, 2010 at 1:55 pm

    crap tips, if you do it, do it right….
    alias update=”sudo apt-get update ; sudo apt-get upgrade”


    alias update=”sudo apt-get update&& sudo apt-get upgrade”

  2. MisterA said on July 6, 2010 at 7:27 pm

    “You have to fire up a new terminal to make sure they work.”
    or just type : source ~/.bashrc

  3. Simon Moon said on July 6, 2010 at 1:18 am

    I keep double clicking on ~/.bashrc in nautilus and it doesn’t do anything. Finally, I opened up my ~/.bashrc with openoffice and now I can’t find a section called “# Alias definitions.” What should I do now!?!?

    Are bashrcs only good for OpenSuse?

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.