In this tutorial, we will talk about how you uninstall a package in Ubuntu distribution using both methods: either using the GUI or by using the command-line environment.
To uninstall or remove a package from the Ubuntu Linux system, you must have root privileges to run the terminal commands.
Methods to uninstall a package in Ubuntu 20.04 system
Using the following two ways, you can uninstall a package from the Ubuntu 20.04 operating system:
- Uninstall a package from Ubuntu using the Terminal (Command-line method)
- Uninstall a package from Ubuntu using the GUI
Method 1: Uninstall a package using the Terminal (Command-line method)
Most Ubuntu Linux users prefer to use the command-line method to uninstall or remove an application from the Ubuntu system. The command-line method offers more control and options for uninstalling the packages.
List installed Ubuntu packages
It is necessary to know the exact package name to uninstall a software or package from your Ubuntu system. Therefore, in Ubuntu 20.04 system, you can view the installed packages by using the following command:
The above command displays the large list of installed packages on your system. but, it would be difficult to find the exact package name from the displayed, installed packages list. To view output in the more readable form, use the ‘less’ with the above command as follows:
Press enter to move on to the next package.
You can also search the exact package name from the whole list by using the grep command as follows:
For example, to find all ‘apache2’ packages, use the below-mentioned command:
Commands to remove a package using Terminal in Ubuntu
The following four most commonly used commands that help you to remove a software package or an application from the Ubuntu system:
Uninstall a package using the ‘remove’ command
To uninstall or remove a package from the Ubuntu system, use the ‘apt-get remove’ command followed by the package name as follows:
You can also remove more than one package at the same time by using the following command syntax:
For example, we want to uninstall ‘zip’ and ‘wget’ packages from the Ubuntu system. Use the below-mentioned command to uninstall these packages:
Uninstall package using ‘purge’ command
The ‘apt-get remove’ command removes the entire package from your Ubuntu system. But, it leaves some packages and configuration files behind on your system. However, to completely uninstall a package including all configuration files, use the ‘purge’ instead of executing the ‘remove’ command. The following ‘purge’ command is used to uninstall a package from the Ubuntu system completely:
For example, to uninstall apache2 packages along with all configuration files from your system, use the below command:
Uninstall unused packages
When you install an application on Ubuntu, it may also download and install the dependencies required to install the application properly. When you uninstall the required packages, the packages dependencies still linger in your system but are unused. These leftover or unused packages can remove from the Ubuntu system by executing the following command:
You can also clean the outdated/ old packages from the cache by running the below-mentioned command:
Uninstall snap packages
The snap package manager is a part of the new Ubuntu versions. So, when you independently uninstall a package using snap, you need a list of all installed snap packages. Using the below-given command, you can easily display the list of all installed snap packages:
Once the installed snap packages list is obtained, use the following command to uninstall the snap package:
For example, to uninstall the ‘discord’ application from the snap list, use the following command:
Method 2: Uninstall a package from Ubuntu using the GUI
The alternative way to uninstall a package is using the Ubuntu software center. The software package manager is available on the left sidebar of your Ubuntu desktop. To access this application click the ‘Ubuntu software’ icon or launch it using the application search bar as follows:
The following Ubuntu software manager window shows on your system. Click on the ‘Installed’ tab to see all installed packages. Here, you can search for an application that you want to uninstall from your Ubuntu system.
Select the application that you want to remove from your Ubuntu machine as follows:
We learned different commands through which you can easily uninstall a package or software from your Ubuntu 20.04 system. Moreover, we also demonstrated how to remove or uninstall a package using the GUI of the Ubuntu software center. You can adopt any method from either uninstalling a package via command-line or using the GUI; these methods are useful for every Linux user.