An alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. This can save a great deal of typing at the command-line and avoid having to remember complex combinations of commands and options.
An alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence.
If, for example, we include alias lm="ls -l | more"
in the ~/.bashrc
file, then each lm
typed at the command-line will automatically be replaced by a ls -l | more
. This can save a great deal of typing at the command-line and avoid having to remember complex combinations of commands and options.
Setting alias rm="rm -i"
(interactive mode delete) may save a good deal of grief, since it can prevent inadvertently deleting important files.
Further reading
In Bash, when to alias, when to script, and when to write a function?
How do I get bash completion for command aliases?
External references
- alias specification (The Open Group Base Specifications Issue 7, 2018 edition)
- Aliases (Bash Reference Manual)
- Aliasing (The Z Shell Manual)
- Alias Substitution (IEEE Std 1003.1: Shell and utilities)
- Advanced Bash-Scripting Guide: Aliases