The purpose of this tutorial is to show how to remove an alias on a Linux system. Aliases can be created to either be permanent or temporary, but it is possible to remove them either way. Check out the steps below to see how.
In this tutorial you will learn:
- How to remove temporary alias on Linux
- How to remove permanent alias on Linux
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
How to remove temporary alias on Linux
If you have created a temporary alias by using the
aliascommand, you can use the
unaliascommand to remove it.
For example, let’s set a temporary alias:
$ alias docs='cd /home/linuxconfig/Documents'
Now, to remove this alias, we would execute:
$ unalias docs
You can verify that the alias has been removed by trying to use it, or by checking the list of configured aliases on your system:
$ alias -p
How to remove permanent alias on Linux
If you have created a permanent alias by editing the
~/.bashrc file, you just need to open this file and remove the corresponding line.
- You can open the file with nano or your preferred text editor.
$ nano ~/.bashrc
- In this file, locate the alias that you wish to remove. Simply backspace the line to delete it completely.
- When done, save your changes to the file and exit it. Then, execute the following command to make the changes take effect:
$ source ~/.bashrc
- You can verify that the alias has been removed by trying to use it, or by checking the list of configured aliases on your system:
$ alias -p
In this tutorial, we saw how to remove an alias on a Linux system. The steps to remove a temporary alias versus a permanent alias are different, but are easy enough to do for any user. You may use the alias command again in the future to create another temporary alias, or edit the
~/.bashrcfile to create a permanent variable that persists after subsequent reboots.