Remove Old Aliases in Linux
1 min read
Parent: Linux Commands & Snippets
How to Remove an Alias in Linux
-
Remove an alias in the current shell session
If you only want to remove an alias temporarily (until you close the terminal), run:
unalias alias_name
Example:
unalias ll
To remove ALL aliases in the current session:
unalias -a
-
Permanently remove an alias
Persistent aliases are stored in your shell configuration files, such as:
~/.bashrc ~/.bash_profile ~/.profile ~/.zshrc /etc/bash.bashrc /etc/profile
Steps to remove permanently:
-
Open your config file:
nano ~/.bashrc -
Find the alias line, such as:
alias ll='ls -la' -
Delete it or comment it out:
# alias ll='ls -la' -
Reload your shell configuration:
source ~/.bashrcOr restart your terminal.
-
Check where an alias is defined
To determine whether something is an alias and what file defines it:
type alias_name
Example:
type ll
If you need to search your config files:
grep -R "alias ll" ~/.*
Replace ‘ll’ with the alias name you are investigating.
Quick Reference
Remove alias (current session): unalias alias_name
Remove all aliases (session): unalias -a
Remove alias permanently: Remove or comment the alias line in ~/.bashrc, ~/.zshrc, etc.
Reload shell config: source ~/.bashrc
Check alias definition: type alias_name