In this tutorial we will see how to create aliases on Ubuntu 12.04/11.10 or older. Aliases will help you assign short words to any terminal command of your choice. This will be very useful for lengthy commands or commands we use frequently like updating repositories (sudo apt-get update), upgrading the system (sudo apt-get upgrade), etc.
Lets first create a hidden file called .bash_aliases in your home directory with this command:
> ~/.bash_aliases; gedit ~/.bash_aliases
To add, for example, an alias for updating repositories, you can add this line to your file:
alias update='sudo apt-get update'
update -----> the name assigned to the 'sudo apt-get update' command. Save your file and exit. To test your alias, close the terminal and start it again, then test your alias by running this command:
'update' will serve as an abbreviation for the 'sudo apt-get update' command. Here are some other alias examples that you can add to the ~/.bash_aliases file:
alias upgrade='sudo apt-get upgrade'
alias inst='sudo apt-get install'
alias autorm='sudo apt-get autoremove'
NOTE: When adding new aliases, you have to restart your terminal so that they are taken into account.