Monday, November 17, 2014

Create aliases in Ubuntu 14.04

How often You must run some long commands in terminal? Even if You do not use "complicated" commands, You probably typed, at least once, the commands for updating Your system.

You know, like this:

sudo apt-get update && sudo apt-get upgrade

This and similar (long) commands can be very iritated, no matter if You use it often. Because of that, You can create aliases for frequently used commands. Alias is shorter command. In example, You can type update to update Your system instead of the above (long) command.

To do this, You need to enter alias for a command in appropriate file. That file is $HOME/.bashrc. It's hidden file, located in Your /home directory. To see it, press ctrl+h key combo. Open the file and scroll down to the bottom. Now, enter aliases for desired commands, like this:

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

See how it looks in my .bashrc file:














I created section My aliases and put there aliases for frequently used commands. You can call it whatever You want.

After You finish this, Save the file. Now, You need to do one more step. Open terminal and type:

source ~/.bashrc

After that, when You want to update Your system, all You need to type in terminal is update.