.bashrc and permanent aliases

Today I came through a concept called aliases in linux. It was pretty interesting topic. An alias is a command that is user-defined built from other commands. For eg, you could build an alias by,

$ alias aliasName=’command1; command2;’

After that you could enter this alias name in the terminal to execute the commands in chain.

.bashrc is a hidden file which is located in your home directory. Some linux based operating systems have them by default, but sometime they are not created by default. If not already present, then you can create it yourself. But remember to create it in the home directory. ‘.bashrc’ is a shell script that is automatically executed by terminal session, whenever it is started. ‘.bashrc’ file allows you to create permanent aliases.

The problem with alias is that they are temporary by default, means aliases will only execute for one terminal session in which it was created. If you create an alias and close the terminal, and then you opened a new terminal session, the previous alias you created won’t work in the new terminal session.

So inorder to solve this problem we need to create permanent alias. For creating permanent alias, simply copy your alias command and paste it into the .bashrc file. So each time you open a new terminal session, the .bashrc file will create your alias for you.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s