The unalias command is a Linux utility that is used to remove an alias that has been defined on the system.
To use the unalias command, you simply need to specify the name of the alias that you want to remove. For example, if you had defined an alias called ll that represented the ls -l command, you could remove the alias with the following unalias command:
This will remove the ll alias from your system, and you will no longer be able to use it in the terminal. You can also use the -a option with the unalias command to remove all aliases that have been defined on the system. For example:
This will remove all defined aliases from your system, so use this option with caution.
To see a list of all the aliases that have been defined on your system, you can use the alias command without any options or arguments.
This will display a list of all the aliases that have been defined, along with the commands that they represent.
Persisting unalias Changes Across Sessions
To make the changes made by the unalias command persist across shell sessions, you will need to remove the alias from your shell's configuration file. The configuration file for your shell is a file that is executed whenever you open a new terminal or shell session.
Removing the alias from this file, will not be defined whenever you open a new shell session, so you won't have to use the unalias command to remove it manually every time.
The name and location of the configuration file for your shell will depend on the type of shell that you are using. Some common shells and their corresponding configuration files are:
- Bash: ~/.bashrc or ~/.bash_profile
- Zsh: ~/.zshrc
- Fish: ~/.config/fish/config.fish
To remove an alias from your shell's configuration file, you can use a text editor to open the appropriate file and search for the alias command for the alias that you want to remove.
For example, if you were using Bash and wanted to remove the ll alias that we used earlier, you could search for the following line in your ~/.bashrc file:
alias ll='ls -l'
Once you have found the line that defines the alias, simply delete it from the file and save your changes.
The next time you open a new shell session, the ll alias will not be defined, and you will not be able to use it in the terminal.
Keep in mind that the changes you make to your shell's configuration file will only apply to new shell sessions. If you have already opened a shell session and want to remove the alias from your current session, you will need to source the configuration file to load the changes into your current shell session.
You can do this by running the following command:
Replace ~/.bashrc with the path to your shell's configuration file if it is different. This will load the changes that you made to the configuration file, and the ll alias will no longer be defined in your current shell session.