How Can You Completely Remove a Package From Ubuntu?

In Ubuntu, a simple package removal leaves some dependencies and configurations as remains of the package. If you are facing storage and poor performance issues, then you must be aware of removing the package completely. Ubuntu offers a variety of packages that have different installation mediums, i.e., apt, dpkg, snap. So, each manager has a different command to completely remove a package.

Keeping an eye on the importance of complete removal, this post serves all the possible methods to completely remove a package in Ubuntu.

1: Completely Remove an apt Based Package

The “apt” is the default package management tool for Debian/Ubuntu-based Linux distributions. The apt manager offers the “remove”, “autoremove”, and “purge” options to deal with the removal of packages.

Here, we will teach you how all these behave on the Ubuntu system:

Remove the Package Only

The remove command is used to remove the package (only executable) from your Ubuntu machine. In this example, we are removing the telegram desktop app.

$ sudo apt remove <package name>

Run the command in your terminal, then write Y to continue and your package will be removed.

The system has successfully removed the package however there are dependences and additional files remaining.

Remove Additional Packages

The purge command is used to remove the configurations installed with the packages. All packages come with their own dependency files, which are necessary for installation, however, when you remove the package these dependencies remain in the system. To get rid of all these, use the command:

$ sudo apt purge <package name>

As an example, the command provided below will remove the telegram’s dependencies:

As you can see, the system has found the dependencies associated with the telegram package and removed them all.

Remove Dependencies

It is necessary to remove the additional packages that get installed along with the package. These packages are supporting files that provide support to the main package so it can function properly.
The general command to remove the dependencies is:

$ sudo apt autoremove <package name>

Write the following command in your terminal window and hit enter.

By following the above steps you have now removed the package, dependencies, and the additional packages installed.

Remove the Package, Dependencies, and Additional Packages at Once

Instead of removing package files one by one, you can also choose to remove the executables, dependencies, and configurations just by using this combined command:

$ sudo apt remove -purge --autoremove <package name>

Write the following command in the terminal and hit enter so that system can start the process to remove packages. Enter Y to continue and the system will remove the packages.

You can see in the above screenshot that the system has executed and removed all packages.

2. Completely Remove a dpkg Based Package

The dpkg package is a Debian-based management package in Linux, it manages the installation, building, and removal of the Debian package. We will be using the following commands to remove a package.

$ sudo dpkg --remove <package name>

Remove command will remove the package completely from your operating system. However, dependencies will remain in this system. To remove the dependencies you will be using the purge command:

$ sudo dpkg --purge <package name>

Note: It is recommended to use the apt command for removing the package. As apt supports all dpkg after the new update of 20.04.

3. Completely Remove a snap Based Package

Snap is a package manager which enables the applications to run over Linux systems. If you have installed packages using the snap command then these packages can only be removed using the snap removal system.
To remove the snap installed packages use the following command:

$ sudo snap remove --purge telegram-desktop

This command will remove the package and also remove all dependencies associated with it.

You have successfully removed all the packages and dependencies along with it. You can also use these commands separately.

4. Completely Remove the Package Using Ubuntu Software

One of removing a file is using the Ubuntu center. Some apt packages and the snap packages are contained inside them. Let’s see how it can be used to remove the package:

Click on the Ubuntu Software icon and open the Ubuntu center, navigate to the installed app, and find the package you looking for to remove it. You can find uninstall button next to your package click it to remove the package.

The system will ask for confirmation to uninstall the program. Click Uninstall to continue.

After that, the system will ask for your password to execute the uninstallation process. Input your password and click authenticate to continue the process.

The system will now remove the package.

Note: There are chances that the dependencies/configuration files may remain after the method. So, it is recommended to use the command line methods.

Wrap Up

The uninstallation of packages depends on the process followed for installation. Like, the package installed using apt can be removed using apt. Similarly, the snap packages can be removed using the snap command. These commands offer various options to completely remove the package from Ubuntu.

All these methods are explained with practical demonstration.

To keep in touch with Linux tips and tricks, stay connected with LINUX GENIE.

Print Friendly, PDF & Email