Linux unalias Command: Remove Command Aliases

unalias is a built-in command that removes aliases registered in the current Bash shell. You can delete a specific alias or remove all aliases with the -a option, but it does not automatically erase the definitions saved in the startup files.

It is useful when unexpected options are applied due to aliases or when it is difficult to execute the original command. Understanding the difference between temporary removal and permanent removal is key.

What is the unalias command?

If alias registers a command name and a replacement string, unalias deletes that registration in the current Bash session. After deletion, if you enter the same name, Bash will look again for the next candidates such as functions, built-in commands, or executables in PATH.

This article is based on Bash. Other shells may have commands with the same name, but supported options and configuration files may differ.

Basic Syntax

unalias [-a] [name...]

Specifying one or more names will remove the corresponding aliases. -a removes all aliases in the current shell.

Removing a specific alias

alias ll='ls -alF'
unalias ll

You can check the state before and after deletion as shown below.

alias ll
unalias ll
type ll

After removing an alias, if there is a function or executable file with the same name, that target can be selected. Do not simply assume that "the command has disappeared"; it is recommended to check the remaining candidates with type -a name.

Removing multiple aliases at once

unalias ll la grep

If there is an undefined alias among the specified names, unalias may return a failure status. Keep this in mind when using the result in automation scripts.

Removing all aliases

unalias -a

-a deletes all the aliases in the current shell. Because it can remove not only personal settings but also aliases provided by the distribution for convenience or safety, use it carefully unless it is a temporary shell aimed at narrowing down the cause of a problem.

To save the current list before deleting, you can output it like this.

alias -p

Difference between temporary removal and permanent removal

Removed only in the current terminal

`unalias` only changes the alias table of the current Bash process. When you close the terminal and start a new shell, aliases in startup files like `~/.bashrc` will be redefined.

Remove in a new terminal as well

To permanently remove an alias, you need to find the configuration file where the alias is defined and delete the corresponding line or comment it out.

grep -n "alias ll=" ~/.bashrc ~/.bash_aliases 2>/dev/null

After modifying the settings, open a new shell or apply them to the current shell with the following command.

source ~/.bashrc

It may also be defined in system-wide settings like `/etc/bash.bashrc` or `/etc/profile.d/`. Before changing system files, consider redefining it in user settings or removing it only in the necessary session first.

Bypass an alias just once without deleting it

If you only want to run the original command once, there is no need to delete the alias. You can either put a backslash in front of the command name or use the absolute path of the executable.

\ls
/usr/bin/ls

A backslash prevents that word from being expanded as an alias. Using the absolute path runs the specified file while avoiding functions with the same name, like PATH searches.

Aliases, functions, and variables have different removal methods

Target Removal Command How to check
Alias unalias name alias name or type name
Shell functions unset -f name declare -F name or type name
Shell Variable unset name declare -p name
Executable file Use file management commands type -a name or command -v name

unalias does not remove functions or files with the same name. If you misidentify the type of the command, the intended target may remain, so check first with type.

Use safely in scripts

To remove only if defined, check the exit status of alias first.

if alias ll >/dev/null 2>&1; then
  unalias ll
fi

However, non-interactive Bash does not perform alias expansion by default, so there are not many situations where a regular script needs to remove user aliases. It is better to write scripts so that they do not rely on the personal settings of an interactive shell.

Common issues

after unalias, the alias reappears in a new terminal.

This is because it is being redefined in ~/.bashrc, ~/.bash_aliases, or system startup files. You need to find the definition location and modify it.

unalias: not found error occurs.

The specified name is likely not an alias in the current shell. Use type -a name to check whether it is a function, built-in command, or executable file.

The command behavior still seems different.

There may be a shell function with the same name or multiple executable files in different paths. Use type -a name to check all candidates, and if necessary, clear Bash's command path cache with hash -r before checking again.

Selection according to usage situation

Situation Recommended Method
Execute the original command only once Use name or the absolute path.
Remove alias in the current terminal Use unalias name.
Temporarily remove the effects of all aliases Check the list and then use unalias -a.
Remove in a new terminal as well Modify the startup file where the alias is defined.
Remove a function with the same name Use unset -f name.

Frequently Asked Questions

Can I recover if I run unalias -a?

There is no function to directly revert the alias definitions of the current shell. Aliases stored in the startup file can be reloaded with source ~/.bashrc, but aliases made only from the command line need to be redefined.

Does unalias affect other terminals as well?

No. Each terminal's shell process has its own separate alias table, so the unalias run in the current shell does not directly affect other shells.

What runs if you enter the same name as the deleted alias?

Bash searches for remaining functions, built-in commands, and executable files in PATH according to the command search rules. The actual selection result can be checked with type name.

Related articles and official documentation

More in This Category
Linux Tutorial / Standard Input, Output, Redirection, and Pipes

Linux Tutorial / Standard Input, Output, Redirection, and Pipes

Understand standard input, output, and error; practice file redirection and pipes; and learn why overwrite risk and redirection order matter.

Linux ethtool Command: Inspect Network Link and Driver Settings

Linux ethtool Command: Inspect Network Link and Driver Settings

Learn how to inspect Network Link and Driver Settings with the Linux ethtool command, including practical examples, key options, and important precautions.

Linux dmesg Command: Read Kernel and Boot Messages

Linux dmesg Command: Read Kernel and Boot Messages

Learn how to read Kernel and Boot Messages with the Linux dmesg command, including practical examples, key options, and important precautions.

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Learn what ls, file, stat, and readlink each reveal about a Linux file, including type, size, timestamps, and symbolic-link targets.

Linux df Command: Check Filesystem Free Space

Linux df Command: Check Filesystem Free Space

Learn how to check Filesystem Free Space with the Linux df command, including practical examples, key options, and important precautions.

Linux apk Command: Manage Packages on Alpine Linux

Linux apk Command: Manage Packages on Alpine Linux

Learn how to manage Packages on Alpine Linux with the Linux apk command, including practical examples, key options, and important precautions.

Linux getent Command: Query Users, Groups, and Other NSS Databases

Linux getent Command: Query Users, Groups, and Other NSS Databases

Learn how to query Users, Groups, and Other NSS Databases with the Linux getent command, including practical examples, key options, and important precautions.

Linux Administration Memo: Essential Commands and System Checks

Linux Administration Memo: Essential Commands and System Checks

A compact Linux administration reference for checking system information, processes, storage, networking, users, permissions, services, and logs.

Linux last Command: Review Login and Reboot History

Linux last Command: Review Login and Reboot History

Learn how to use the Linux last command to review user login sessions, system reboots, and shutdown history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux unalias Command: Remove Command Aliases

Linux unalias Command: Remove Command Aliases

Learn how to use the Linux unalias command to remove one or all aliases from the current shell session, with essential options, practical examples, output interpretation, and common troubleshooting tips.