create command alias in ubuntu

21 Feb 2012

              Are you lazy enough to think of custom Linux command instead of using long commands repeatedly while you are on development? Then this post is for you. This post will help you to set custom shortcut for a command which you use multiple times a day.
           alias command which will help us to create the custom shortcut commands.

 alias db="mysql-uroot -proot"

This will create a temporary alias or short cut command "db". It will last till you end this session or closing the terminal. Now just try to enter "db" in terminal.

So If you want to create a permanent alias you have to go through some more steps.

  1. Create ~/.bash_aliases if not exists
    touch ~/.bash_aliases
  2. Open ~/.bash_aliases in a editor and append alias db="mysql -uroot -proot"
    or use command echo 'alias db="mysql -uroot -proot"' >> ~/.bash_aliases
  3. Save it
  4. Use reload source ~/.bash_profile command to reload profile or reopen the terminal
Thats it. You have done it.
If you particularly enjoy my work, I appreciate donations given with Gittip.