Tuesday, February 07, 2006

Alias

Alias is a really useful command especially for lazy guys like me. Alias literally means "other name", and in linux also it serves the same purpose.When u don't wanna type long commands , what you can do is simply type an alias for it, it's just like making a shortcut.
For example, considering the folowing line

alias movie='mplayer /mnt/win_e/movies/English/Documentary.avi'

If u wanna watch a movie called Documentary which is in the folder /mnt/win_e/movies/English using mplayer , you have to type the full command within the quotes, but if u set an alias like movie, you just need to type movie in terminal.So simple and easy .The alias need not be a word , u can even put letters as aliases.

The aliases which u type last only for the current session, so in order to make them permanent, u need 2 add these aliases in ur bashrc file.
Go to the home folder of which ever user u wanna add the aliases.Using n-e editor open .bashrc file

vim ~/.bashrc

just add the command in the above mentioned format in the .bashrc file and save it.Next time when u restart ur comp , the alias will be a permanent fixture in your path.

few more examples for alias usage:
alias byebye='logout'


So when u type byebye , the logout command is executed. So simple isn't it.
For more info on bashrc and alias i would suggedt u Google.
Else in console type
man alias