How to Remove/Uninstall Packages on Ubuntu 22.04

Ubuntu or any other operating system user relies on the timely removal of unused packages. The removal/uninstallation process removes the package and dependencies/configurations which ultimately frees up the space.

Ubuntu offers various mediums to install packages, i.e., default repositories, deb packages, snap, flatpak, source code, or AppImage. All these sources have different command syntaxes to remove/uninstall the package.

This post will list the possible methods to remove/uninstall the packages from Ubuntu 22.04.

Prerequisites: Check the Existence of the Package

Before digging into this, you must check which package you are going to remove and its source. For that,

go through the guide, List of Installed Packages on Ubuntu to learn the possible ways to list the installed packages on Ubuntu, which confirms the source as well as the exact package name.

How to Uninstall/Remove Packages on Ubuntu 22.04

We have categorized the removal/uninstallation method based on the sources from where these packages are installed. Here’s the list of subsections to be discussed here:

Remove/Uninstall an apt-Based Package

The apt package manager refers to the deb packages and packages of default repositories. The apt offers multiple variants to remove/uninstall any package. Let’s go through the commands:

The simple “remove” option removes the executable and very few necessary dependencies only:

sudo apt remove <package-name>

The “autoremove” removes the package and its dependencies (where no other package depends on these dependencies):

sudo apt autoremove <package-name>

The “autoremove” when used with the “–purge” removes the package, dependencies, and any configuration files associated with that package.

sudo apt autoremove <package-name> --purge

Note: You can use the autoremove and purge commands explicitly after removing/uninstalling the package.

Remove/Uninstall a dpkg-Based Package

Although, it is recommended to utilize the “apt” command wherever you need to exercise dpkg. However, dpkg itself is a fully equipped package manager that allows you to uninstall the package, as follows:

The “-r” Remove the package and some necessary dependencies:

sudo dpkg -r <package-name>

The “-P” purges the package, it removes the configuration files alongside the package executable:

sudo dpkg -P <package-name>

Moreover, use the “–force-all” after the -P or -r flag to add the forceful removal flavor as well.

Remove/Uninstall a snap-Based Package

Snap is another package manager that offers tens of packages. The packages installed from Snap are known as snaps. Here are the possible ways to remove/uninstall snaps from Ubuntu:

The “remove” command removes the mentioned snap alongside any unused dependencies:

sudo snap remove <snap-name>

To remove the snap and its configuration files, use the “–purge” option:

sudo snap remove --purge <snap-name>

Remove/Uninstall a flatpak/flathub-Based Package

Flatpak is the package manager that fetches/installs the applications from the flathub repository. The flathub offers the application ID of the available package which can be removed using the command:

flatpak uninstall <app-id>

To remove the unnecessary libraries as well, use the command:

flatpak uninstall --unused

Remove/Uninstall a Source-Based Package

Different application providers offer the source code support of the specific package. The source code is configured, compiled, and installed (by executing the binaries obtained from compilation/configuration). Let’s see how it can be uninstalled:

The source code-based packages are installed using the “make install” command. To uninstall that package, navigate to the directory (where you had executed the make install command) and use the below command:

make uninstall

Important: In most cases, the uninstall script is available. However, it is possible that you might not get the uninstall script with every source-based package. In such a case, you have to manually delete the directories/files where the source code was configured/compiled/installed.

sudo rm -r <Path-of-Directory>

Remove/Uninstall an AppImage-Based Package

AppImage is the ready-made executable for any application. You just have to download the AppImage, make it executable, and you are good to go with that package. The uninstallation/removal of the package is possible by removing/deleting the AppImage file.

sudo rm <Path-of-AppImage>

The above methods refer to the terminal. Ubuntu has some GUI support to manage the packages. Let’s discuss those now:

Remove/Uninstall a Package Using the Ubuntu Software Centre | GUI

Ubuntu software centre integrates default repositories and snap-supported packages. It is used to install/uninstall/update the supported packages. Let’s see how it removes the packages:

Open the Ubuntu software centre, go to the “Installed tab, and click on the package you want to remove (you can search for that package as well):

You need to follow the onscreen instructions to complete the removal process.

Remove/Uninstall a Package Using Synaptic Package Manager | apt GUI

Synaptic is the GUI of the apt. Any package that can be installed/managed with the apt command, can also be managed via Synaptic. It is not installed by default. However, most Ubuntu users love to keep it on the system as it is a fully loaded GUI support of apt packages.

To remove any package installed via apt/synaptic, open the Synaptic Package Manager from the applications menu and search for the package you want to remove. Then, right-click on the package and select “Mark for Removal”:

This marking selects the package and any dependencies as well. Click “Apply” to remove the package:

It shows the details of what is being removed or how many packages will be held back after this:

These are all the methods to remove/uninstall packages on Ubuntu 22.04.

Bottom Line

Removing or uninstalling any package from Ubuntu is necessary to keep the system clean and spacious. Ubuntu has a wide range of package managers/repositories, through which packages can be managed.

To remove/uninstall any package from Ubuntu 22.04, you need to identify the source of the package (from where you have installed the package). Then, use the appropriate package manager with the required options (depending on the user) and the package will be removed.

This post has provided all the possibilities to remove/uninstall the package from Ubuntu 22.04.

Print Friendly, PDF & Email