The “unalias” Command in Linux [3 Practical Examples]

LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now

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.Showing the list of all alias on my machine.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.Showing the process of removing a single alias with unalias command in linux.



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.Showing the process of removing multiple aliases with unalias command in linux.

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.Showing the process of removing all aliases at a time with unalias command in linux.

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

Rate this post
S. M. Amdadul Islam

Hello everyone. I am S. M. Amdadul Islam, currently working as a Linux Content Developer Executive at SOFTEKO. I am a Naval Architecture and Marine Engineering (NAME) graduate from the Bangladesh University of Engineering and Technology. In addition to my regular work, I enjoy watching Youtube, discovering new things, gossiping with friends, visiting new places, and taking photos of landscapes. Read Full Bio

Leave a Comment