Tuesday, September 14, 2010

Alias - A Great Tool

"Alias" in Linux has its own importance. It was helpful to me by the following means-

1. Saves time by reducing the typing.
2. No need to remember typical commands, paths.
3. No need to remember IP addresses of all the servers(where there is question of maintaining more than 50 servers)

alias ='command'

Here,

shortcut refers to the convenient word to be used instead of typing the whole command.

For example, if you need to login to a server through ssh , generally you type-

ssh -p 99 username@servername or ipaddress

With alias, you can bind this entire command to just a single word of your choice.

alias ns='ssh -p 99 username@servername or ipaddress'

Now you can simply type ns in the shell and it will directly connect you to the server. No need to type the entire ssh command each and every time login is required.


Few More Examples -

Bind a long typical path (which you use very frequently) with alias

alias domain='/var/www/html/manage/network/domains/'


Typing domain at the shell will directly put you inside the directory domains which is located at /var/www/html/manage/network/domains/

alias l='ls -la'

This will execute the command ls -la everytime you just type l.