Skip to content

unalias command in Linux

The Linux unalias command is used to remove an alias that has been previously created with the alias command. This can be useful when you no longer need a specific alias or when it is causing conflicts with other commands. By unaliasing a command, you can revert it back to its original form and ensure smooth operation of your command-line interface.

unalias Syntax:

Terminal window
unalias [options] name [name...]

Linux unalias Options:

OptionDescription
-aRemove all alias definitions.

unalias Parameters:

ParameterDescription
nameThe name of the alias(es) to be removed.

How to use unalias command:

Remove an Alias

Terminal window
unalias ll

Removes the alias “ll”, typically used for the “ls -l” command.

View List of Aliases

Terminal window
unalias -a

Clears all user-defined aliases.

Remove Multiple Aliases

Terminal window
unalias la ls ll

Removes the aliases “la”, “ls”, and “ll” all at once.

Remove Alias with Special Characters

Terminal window
unalias 'cd ..'

Removes the alias with special characters such as space, in this case, an alias for “cd ..“.

Restore Original Command Functionality

Terminal window
unalias cp

Restores the original functionality of the “cp” command if it was previously aliased.

Remove Newly Created Alias

Terminal window
unalias newalias

Removes a newly created alias named “newalias”.

Undo Aliases from a Script

Terminal window
unalias -m

Unsets all aliases that might have been set in a script using the -m option.

Display Unalias Command Help

Terminal window
unalias --help

Shows the help information for using the unalias command.

unalias Command Troubleshooting Q&A:

How do I use unalias in Linux?

To use the unalias command in Linux, execute the following command:

Terminal window
unalias --option <value>

How can I remove a specific alias using unalias in bash?

To remove a specific alias using unalias in bash, you can simply provide the alias name as the argument. For example:

Terminal window
unalias myalias

How do I remove all aliases at once with unalias in Linux?

To remove all defined aliases at once using unalias in Linux, you can use the following command:

Terminal window
unalias -a

Can I use wildcards with unalias in Linux to remove multiple aliases?

Yes, you can use wildcards with unalias in Linux to remove multiple aliases. For example, to remove all aliases starting with “foo”, you can use:

Terminal window
unalias foo*

How do I show a list of currently defined aliases in bash?

To display a list of currently defined aliases in bash, you can use the following command:

Terminal window
alias

Is it possible to remove an alias that is a built-in command with unalias in Linux?

No, you cannot remove an alias that is a built-in command using unalias in Linux.

How do I use unalias to remove an alias with a specific option in bash?

To remove an alias with a specific option using unalias in bash, you can specify the exact alias along with the option. For example:

Terminal window
unalias --option myalias

Can I remove a user-created function with unalias in Linux?

No, the unalias command in Linux is specifically for removing aliases, not user-created functions.

How can I check if a specific alias exists before trying to remove it using unalias in bash?

To check if a specific alias exists before attempting to remove it using unalias in bash, you can use the alias command followed by the alias name. For example:

Terminal window
alias myalias

Applications of the unalias command

  • Removing a specific alias definition
  • Clearing all alias definitions at once
  • Restoring the original command behavior for an aliased command