
unalias Command in Linux
The unalias command in Linux is a useful tool that helps you take away aliases in your current shell session. Aliases are like shortcuts or personalized commands that you create with the alias command. These shortcuts make it easier to use commands that you often repeat or find complex.
Even though aliases can be very handy, there are times you might want to get rid of them or temporarily turn them off. In those situations, the unalias command is what you need to use.
Table of Contents
Here is a comprehensive guide to the options available with the unalias command −
- What is unalias Command in Linux?
- Syntax of unalias Command
- unalias Command Options
- Examples of unalias Command in Linux
- Permanently Removing Aliases Command
What is unalias Command in Linux?
The unalias command is used to delete one or more aliases from the current shell session. It ensures that the specified alias no longer overrides the original command or function. This is particularly useful when an alias conflicts with a system command or when you no longer need a custom alias.
It's important to note that unalias only removes aliases for the current session. If the alias is defined in a configuration file (e.g., .bashrc or .zshrc), it will be restored the next time the shell is restarted unless it is removed from the configuration file as well.
Syntax of unalias Command
The basic syntax of the unalias command is −
unalias [OPTION] [ALIAS_NAME]...
Where,
- [OPTION] − Adjusts the way the command functions.
- [ALIAS_NAME] − Indicates the alias name you wish to delete. You can list several aliases by separating their names with spaces.
unalias Command Options
The unalias command comes with a few simple options that help manage and remove aliases effectively in Linux.
Options | Description |
---|---|
-a | Removes all aliases defined in the current shell session. This is useful for resetting the shell to its default state. |
--help | Displays a help message with information about the command and its options. |
Examples of unalias Command in Linux
Below are several practical use cases for the unalias command on a Linux system.
- Removing a Specific Alias
- Removing Multiple Aliases Simultaneously
- Resetting All Aliases
- Temporarily Removing an Alias
- Verifying if an Alias Has Been Removed
Removing a Specific Alias
Aliases often serve as shortcuts, but sometimes you may need to disable a specific alias that's no longer required −
unalias ll
This command removes the alias ll, which is often used as a shortcut for ls -l. Once removed, typing ll will no longer execute the alias unless it is redefined or restored from a configuration file.

Removing Multiple Aliases Simultaneously
When several aliases are causing conflicts or are no longer needed, you can remove them all at once −
unalias ls ll la
This example deletes the aliases ls, ll, and la in one command. This approach is especially helpful when cleaning up a shell environment for debugging or resetting.
Resetting All Aliases
For a complete reset of the current session, you can clear all active aliases −
unalias -a
The -a option removes all defined aliases from the session. This ensures no alias modifications interfere with commands, restoring the shell to its default state. It's particularly useful during testing or when troubleshooting unexpected behaviors caused by aliases.

Temporarily Removing an Alias
Sometimes, you may want to test how a command behaves without its alias. In such cases, you can temporarily disable the alias −
unalias grep
If you have an alias for grep (e.g., alias grep='grep --color=auto'), running this command removes it for the current session. The original grep command will now execute. The alias will, however, be restored in the next session if it's defined in the shell's configuration file.

Verifying if an Alias Has Been Removed
After running the unalias command, you might want to confirm that the alias no longer exists −
unalias ll alias ll
The first command removes the alias ll, and the second command checks if it still exists. If the alias was successfully removed, the second command will produce no output.

Permanently Removing Aliases Command
While the unalias command is effective for temporary removal, aliases will be restored in subsequent sessions if they are defined in the shell's configuration file (e.g., .bashrc, .zshrc, or .bash_aliases). To permanently remove an alias −
Step 1 − Open the shell configuration file in a text editor −
nano ~/.bashrc
Step 2 − Locate and delete the line that defines the alias −
alias ll='ls -l'
Step 3 − Save the file and reload the configuration −
source ~/.bashrc
Once removed from the configuration file, the alias will no longer be loaded in future sessions.
Conclusion
The unalias command is a helpful tool for managing aliases in Linux. If you need to remove one alias, several at once, or even clear all aliases for a single session, unalias can assist in keeping your shell environment clean and efficient. It's easy to use and very flexible, making it perfect for troubleshooting, testing out new configurations, or resetting your shell settings.
When you learn to use unalias effectively, you can take better control of your aliases, which leads to a more enjoyable command-line experience.