Aliases
Allowing linux users to define alternative names for commands
Aliases allow Linux users to define alternative names for commands. The alias is translated by the shell and the original command is executed. Aliases can be defined on the command line, in .bash_profile, or in .bashrc, using the general syntax 'alias name=command'. Aliases are normally used to make long commands short. Consider the following frequently issued command: "Java Java/build/classes/myProgram < myinput.txt1 myinput.txt2". The user may set up an alias for the program as follows:
[ LinuxUser ] /usr/bin$ alias runjava='java Java/build/classes/myProgram < myinput.txt1 myinput.txt' [ LinuxUser ] /usr/bin$ runjava
Note that the user has to type 'runjava' to run the long command after creating an alias. Aliases stored in .bashrc or .profile are always available to the user. Aliases are often used to make the optional behavior of a command its default behavior in the following way:
[LinuxUser:Sun Nov 26] ~$ alias ls='ls -a' [LinuxUser:Sun Nov 26] ~$ ls . .bash_history .bashrc .ssh errors.txt .. .bash_profile .inputrc errors lsinfo.txt [LinuxUser:Sun Nov 26] ~$
The above alias effectively re-defines the ls command to always display hidden files by making it an alias for the ls command with the 'a' option. Typing 'alias' at the command prompt returns a list of current aliases.