FUNDAMENTALS A Complete Guide for Beginners
Sometimes you use several combinations of commands or large commands with huge options repeatedly. To make this task easier, you can create an alias. If you no longer need the alias, then the unalias command is used to remove that. In this article, I will describe the features and uses of the unalias command in Linux with examples.
A. Description
The unalias command is used to eliminate items from the list of aliases for the current user, specifically those added during the current login session. Permanent aliases may also be temporarily suppressed; however, they will be restored once the user logs in again.
B. Syntax
The syntax of the unalias command in Linux is pretty simple, as shown below.
unalias [OPTION] [ALIAS_NAME]...
Note: In the syntax above, the OPTION enclosed by the square bracket means it is not mandatory and three dots after the square bracket mean multiple alias can be used after the unalias command.
C. Options
There is only one option available for the unalias command. Here, I have described that one below.
- -a: Remove all alias for the current user for the current shell for the current session
In addition to that, you can learn more about the unalias command, its option and its uses by checking the help page.
help unalias
Note: Commands and their options are case-sensitive in Linux. So, be careful while using them.
Practical Examples of the “unalias” Command in Linux
In Linux, the unalias command is a helpful tool to remove alias for the current user for the current shell for the current session. In the section below, I will show you some of the most useful applications for the addgroup command in Linux.
Example 1: Remove a Single Alias With the “unalias” Command in Linux
The unalias command is useful to remove the alias that already exists in your system. Here, I’ve previously created multiple aliases on my machine, a list of them is displayed in the image below.Now, I will remove an alias named “lbb” with the unalias command. You can do the same by following the steps below.
Steps to follow >
➊ At first, open the Ubuntu Terminal.
➋ Run the command below:
unalias lbb
➌ Now, press the ENTER button.
➍ Then, type the following command into the command prompt:
alias
➎ Press ENTER again.
Output >
Here, In the following image, you can see that I have removed the alias lbb.
- The “echo” Command in Linux [7 Practical Examples]
- The “alias” Command in Linux [3 Practical Examples]
- The “exit” Command in Linux [5 Practical Examples]
Example 2: Remove Multiple Aliases With the “unalias” Command in Linux
The unalias command in Linux allows you to remove multiple aliases at a time. Here, I’ll use the unalias command to simultaneously eliminate two aliases with the names “lc” and “lcc.” By using the steps listed below, you can achieve the same results.
Steps to follow >
➊ First, launch the Ubuntu Terminal.
➋ Now, execute the following command:
unalias lc lcc
➌ At this point, press ENTER.
➍ To verify the existence of those two aliases, run the following command
alias
➎ Press ENTER again.
Output >
The aliases lc and lcc are no longer present as you can see in the following image.
Example 3: Remove All Aliases at a Time With the “unalias” Command in Linux
You can remove all the aliases together by executing the unalias command with the option -a. Here, I’ll use the unalias command with option -a to remove all existing aliases. You can achieve the same outcomes by following the steps listed below.
Steps to follow >
➊ First, open the Ubuntu Terminal.
➋ Run the command below:
unalias -a
➌ Now, press the ENTER button.
➍ Type the following command into the command prompt:
alias
➎ Press ENTER again.
Output >
You can see in the following image that I have eliminated all of the aliases.
Conclusion
In this article, I have discussed the unalias command and its use. I also provide some useful examples that will help you better understand the unalias command and will help in your journey to becoming a power user of the command line. Finally, I wish you a prosperous learning journey!
Related Articles
- The “bash” Command in Linux [5 Practical Examples]
- The “clear” Command in Linux [3 Practical Examples]
- The “declare” Command in Linux [7 Practical Examples]
- The “export” Command in Linux [8 Practical Examples]
- The “source” Command in Linux [3 Practical Examples]
- The “hash” Command in Linux [6 Practical Examples]
- The “read” Command in Linux [8 Practical Examples]
- The “set” Command in Linux [6 Practical Examples]
- The “unset” Command in Linux [2 Practical Examples]
- The “eval” Command in Linux [4 Practical Examples]