Aliases are nicknames of sorts that you use to enter commands more easily. For example, if you frequently use the command mail -s "Lunch today? deb .signature, you could set an alias for this command and call it lunch. Then, in the future, all you have to do is type in lunch, and the result is the same as if you typed in the longer command (Figure 8.7).
To set an alias with alias:
1. |
Choose the appropriate file to edit, depending on which shell you're using.
|
2. | vi .bashrc Edit the configuration file you've selected. |
3. | alias quit="logout" Type alias followed by the term you want to use as the alias, =, and the command you're making an alias for (in quotes). Here, we're setting the word quit as an alias for the system command logout, so we can type quit instead of logout (Figure 8.7). |
4. |
Add as many other aliases as you want. See the sidebar called Good aliases to set in this section for more ideas. |
5. |
Save the file and exit from the editor. See Chapter 4 for details about saving and exiting in vi and pico. |
6. | su - yourid Start a new login shell to test out the alias. |
7. | alias Type alias at the shell prompt for a listing of all the aliases you have defined (Code Listing 8.18). |
Note
You can put aliases in other files, but it's customary to put them in the .bashrc (or other appropriate rc file, such as . kshrc or .cshrc), so they'll be set automatically when you log in, rather than having to be manually set.
Note
You can also issue alias commands from the shell prompt to set aliases for the current session.
Note
Be sure to make a backup copy of any configuration files you plan to change before you change them. That way, if you mess up, you still have the original file to work with.
Good aliases to setHere are a few aliases that you might find it worthwhile to set on your system:
Or, if you're coming from a DOS background, you might find the following aliases handy:
|
3.138.37.20