Command Aliases

The 'alias' command enables you to create another name for a command.

The alias doesn't replace the original command, though; it's simply a

synonym for it. You define an alias using the 'alias' command followed

by an equal sign and the command that the alias will stand for. For

example, the following command defines 'list' as an alias for 'ls':

$alias list=ls

You use this alias as you would use the original 'ls' command:


mypog.c myprog.o

Command Options and Parameters

To include command options in an alias, enclose the command and its

option(s) in single quotes:

$alias sizes='ls -s'

The -s option lists files with their sizes in blocks. Therefore, the

alias 'sizes' displays the files in the current directory with their

sizes in blocks:


mypog.c 6 myprog.o 12

You may include command parameters in an alias. The following alias

displays only files with the .c extension:

$alias listc='ls *.c'



You can use an exiting command name as an alias, too. In this case, the

alias hides the original command. Use this feature to hide dangerous

commands that might delete files inadvertently, change their names,

etc. Let's look at a concrete example. To ensure that 'mv' command

doesn't overwrite exiting files, define an alias called 'mv' that

overrides the 'mv -i' command (the -i option queries the user before

deleting existing files):

$alias mv='mv -i'

Listing and Canceling Existing Aliases

To list all the aliases in effect, use the 'alias' command without

additional parameters:


list = ls -s

sizes = ls -s

listc = ls *.c

rm = rm -i

To cancel an exiting alias, use the 'unalias' command followed by the

alias you wish to remove:

$unalias listc

ITWorld DealPost: The best in tech deals and discounts.
Shop Tech Products at Amazon