Aliases allow you to use a command in place of another command or series of commands. To create an alias, type:

    alias <alias_name> <command_to_be_aliased>

    Example: alias dir ‘ls -al

This example will execute ls -al whenever you type dir. If
the command to be aliased contains any spaces, it must be surrounded by single quotes.

Common aliases include:

    alias ll ‘ls -l
    alias la ‘ls -a
    alias f finger

Aliases that are typed at the Unix prompt will last for the current login session. If you want to have aliases automatically set up when you log in, use a text editor such as
emacs, or
vi to put your alias commands at the bottom of your .login
file. You can also put the commands at the bottom of your .cshrc or .tcshrc file.

To cancel the alias, type:

    unalias <alias_name>
    Example: unalias dir

Listing Aliases

To see a list of all the aliases you have created, simply type:


To see what command a particular alias is set to, type:

    alias <alias_name>
    Example: alias dir

This example will output ls -al if you created the dir alias above.

Using Command Line Input in Your Alias

If you want your alias to read command line input, type:

    alias <alias_name> ‘command \!*
    Example: alias ldir ‘ls -al \!* | more

This example will give a long listing of a directory you specify and then pipe it through the “more” command. So if you type ldir bin, the command ls -al bin | more will get

If the command line input is at the end of the alias, then you do not need to include \!*. The following example will print whatever file you specify as a command line input to the printer in UCC101. So, if you type “print essay1”, the command “lpr -Pps_ucc101 essay1” will be executed.

    Example: alias print ‘lpr -Pps_ucc101 \!*’
    Example: alias print ‘lpr -Pps_ucc101′

Using a Command Name as an Alias Name

You can create an alias name that has the same name as a UNIX command.

    Example:alias edit pico

There is already a Unix command called edit. However, when you type in a command, your list
of aliases is searched before the Unix commands are searched. Therefore, if you were to type edit, your alias called edit would get executed, not the Unix command edit.

If you wanted to temporarily override your alias and execute the real edit command, you may
specify the full path to the edit command such as /usr/bin/edit.