Unix Concepts   «Prev  Next»
Lesson 3 Managing aliases
Objective List current aliases and disable them.

List Current Aliases in Unix

Once a few aliases have been defined, you can manage them in different ways, as shown below:
% aliasList currently defined aliases
% alias nameList the definition for the alias name
% alias | grep patternList all definitions that contain pattern
% \commandTemporarily disable the alias. Use the default command, not the alias by that name
% unalias nameDisable the alias definition for name for the rest of your UNIX session

These commands are demonstrated in the following ToolTip: Mouseover the image below to obtain more information.

Alias Example

Unix Aliases
  1. Without arguments, the alias command displays a list of defined aliases. The parentheses, ( ), indicate that the definitions are treated as a single argument.
  2. With a single argument (the alias name rm), the alias command displays rm –i, the alias definition.
  3. You want to remove the file qa.html. However, the rm command is really an alias for rm -i. As a result, the command prompts for confirmation.
  4. To use the regular rm command, you need to disable the rm alias. This is done with the backslash (\). Now, the actual rm command is used, and the file is deleted without confirmation.
  5. If you have many aliases, the grep command can help you find them. In this example, grep searches for aliases that contain the pattern ls.
  6. To disable an alias for the rest of your UNIX session, use the unalias command.
  7. Because you have disabled the ls alias, it no longer appears when you search for it.

Managing Aliases
In the next lesson, the display of previous commands using the history feature will be discussed.

Creating Managing Aliases

Click the Exercise link below to test your knowledge of aliases.
Creating Managing Aliases