Creating Bash Aliases
Posted on 05. Mar, 2009 by Nikhil Sheth in Browsers, Knowledge, Linux
What is an alias?
An alias is basically a shortcut for a command you place in your ~/.bashrc file. Aliases cut down on typing and can save you from having to look up a command.
Aliases are set up near the bottom of the of the .bashrc file. You’ll see a commented-out section that indicates where you should put them. The format of an alias is:
Alias NICKNAME=’full command here’
The keyword alias must be used. The nickname is what you will type at the command line. Make this nickname easy to remember. The = sign must also be used. After the = sign, you enter the full command, including flags and switches, enclosed in single quotes. Once you are done, save the .bashrc file and open up a new terminal. I always find it best to leave the original terminal window open in case there are problems. In the new terminal, type the alias nickname and the command will run.
For example you can create ssh alias
alias server_name=’ssh -v -l USERNAME IP ADDRESS’
Just change server_name to a memorable name for the server. Then, change USERNAME and IP ADDRESS to suit your needs.
Related posts:

Leave a reply