Working with Bash Aliases (Alias/Unalias)

Shell Tips
August 25, 2007 | COMMENTS

Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases that may be set and unset with the alias and unalias builtin commands.

You can set your aliases into your .bashrc file. Following some common aliases:

alias ls=’ls -color=auto’
alias dir=’ls -color=auto -format=vertical’
alias vdir=’ls -color=auto -format=long’
alias ll=’ls -l’
alias la=’ls -A’
alias l=’ls -CF’

All this is nice but how can you unset all this stuff ? Simple ! Use unalias builtin command.

# unset "ll" alias
unalias ll

# unset all aliases
unalias -a

Aliases are not expanded when shell isn’t interactive, unless the expand_aliases shell option is set using shopt.

shopt -s expand_aliases