Tuesday, January 11, 2005

How to Use the "alias" Command

In Linux/UNIX, the alias command is a shell function that allows you to substitute one command for another. Aliases are also handy for assigning default arguments to commands, such as ensuring that the “-i” (interactive) option is always used with “cp” and “mv”.

The syntax for the alias command is: #alias [new command]=”[command with arguments]” #alias cps=”cp -s” would create the new alias “cps” which would always invoke the “cp” command with the symbolic link argument.
You can see existing aliases by issuing the alias command with no options at a command prompt.

Aliases can be removed with the unalias command: #unalias cps will remove the “cps” alias.

Get hands-on practice using the alias command and lots of other commands in our two-day Linux hands-on seminar available in open-enrollment public seminars or you can schedule it in the location of your choosing for groups of four or more as an onsite seminar.

No comments: