Shell Aliases
An alias gives a longer command a short name. Aliases save typing for commands you run often.
Give a command a short name
alias makes greet stand for echo Hello. alias greet shows the new name.
alias greet='echo Hello'
alias greetList your aliases
alias with no argument lists every alias in this shell.
alias ll='ls -l'
alias docs='ls docs'
aliasRemove an alias
unalias removes the name. The list is empty after this.
alias greet='echo Hello'
unalias greet
alias
echo "Alias list is empty."Example
alias ll='ls -l'
alias notes='cat notes.txt'
alias
unalias notes
alias llKey points
- Alias: a short name you give a longer command.
- Use alias to give a command a short name.
- Use alias with no argument to list all aliases.
- Use unalias to remove an alias.
In this example, two aliases are made and listed. unalias notes removes one, and alias ll shows the one that is left.
Note
An alias lives only in the current shell, unless you save it in a startup file.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does unalias ll do?