Wednesday, 18 June 2008

Linux Command: alias

The alias command is used for creating shorter meaningful synonyms for longer, complex and sometimes meaningless shell commands.
Few years ago when I started being interested in all 'free' and 'open' things that Linux OS gives I also started being more an more frustrated typing some commands over and over again. Than I descovered aliases. Oh lucky me.
Most of advanced or even beginner Linux users already know this, but those that don't will find it quite handy in future.
Syntax goes like this:
alias [synonym]='[true shell command]'

Real examples might be:
alias lsa='ls -all -F'

Now if lsa is typed in a shell it will automatically run command ls -all -F. Saves so much typing.
Aliases are most efficient if they are defined at a shell startup time. To do that all that's needed is to put the line at the end of your bash profile file which is usually full of commands that run at shell startup and user mostly don't even know or think about it. Look for the file named '.bashrc', '.bash-profile' or simply '.profile' in your home directory.

No comments: