How do I create an alias to a common command?
Author: Deron Eriksson
Description: This Linux tutorial demonstrates how to create an alias to a common command.
Tutorial created using: CentOS release 4.6
The "alias" command can be used to create an alias, which is a name that represents a particular string such as a command. It can be useful to add aliases to your .bashrc file in your home directory so that you will get your aliases each time you log on to Linux.
Below, I created two aliases in .bashrc. The first one creates an alias called "tell-me-the-date" to represent the date command (in a normal situation, you would use an alias to create an alias shorter than the command, not longer like in this example). The second alias is called "monkey", and it's value is an echoing to the terminal of the text "oo-oo-oo aa-aa-aa".
alias tell-me-the-date="date" alias monkey="echo oo-oo-oo aa-aa-aa"
After saving my .bashrc file, I log off and log back on so that I get the new aliases that I created. I can list all aliases by typing "alias" with nothing else. After this, I type "tell-me-the-date", and we can see that the current date/time is displayed. After that, I type "monkey" and "oo-oo-oo aa-aa-aa" is echoed to the screen.
Aliases are a great way to represent shortcuts to long commands that you find yourself typing over and over.