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.

Share and Enjoy:
  • Twitter
  • Digg
  • StumbleUpon
  • Facebook
  • del.icio.us
  • Yahoo! Buzz
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Technorati
  • Yahoo! Bookmarks
  • DZone

Related posts:

  1. 4 Ways To Search For Files Using The Terminal
  2. To HUP or nohup?
  3. Creating animations from Images and Videos
  4. Command Line Kung Fu Developer
  5. Find a Future Date from the Shell

Tags:

Leave a reply

Anti-Spam Protection by WP-SpamFree

Get Adobe Flash playerPlugin by wpburn.com wordpress themes