How to Uninstall or Remove Packages in Ubuntu

May 23, 2024

Introduction

During software installation, package managers download and install the main binary package and all the necessary dependencies. Once the application is no longer needed, it is advisable to remove it since its packages take up storage space and may hinder performance.

This guide teaches you how to uninstall or remove packages in Ubuntu using the command line or GUI.

Prerequisites

  • Ubuntu installed (this tutorial uses Ubuntu 22.04).
  • Command-line access.
  • A user account with sudo privileges.

Uninstall Packages in Ubuntu via CLI

The default Ubuntu command-line application management tools are APT, DPKG, and Snap. Each utility provides methods for uninstalling and removing software from the system.

Read the sections below for instructions on uninstalling packages using the Ubuntu CLI.

Option 1: Uninstall Ubuntu Packages with APT

The APT package manager offers several ways to remove unwanted packages. The most common way to uninstall an app with APT is to use the apt remove command:

sudo apt remove [package]

For instance, to remove the curl tool from Ubuntu, type the following command:

sudo apt remove curl -y

Adding the -y argument to the command auto-approves all queries during uninstallation.

Uninstalling curl using the apt remove command.

The apt remove command uninstalls the application but does not remove configuration files. To clear packages from the system completely, use apt purge. The purge option deletes packages and removes all dependencies:

sudo apt purge [package]

For instance, delete curl and its configuration files by typing:

sudo apt purge curl -y

Remove outdated packages' cache by using the apt clean utility. To clear the cache from an Ubuntu system, run:

sudo apt clean

The command prints no output.

Option 2: Uninstall Ubuntu Packages with DPKG

The DPKG utility is a low-level packaging tool in Debian-based systems like Ubuntu. To use DPKG to remove a package, enter the following command:

sudo dpkg -r [package]

For instance, to remove curl, run:

sudo dpkg -r curl
Uninstalling curl using dpkg.

Adding the -P option tells DPKG to remove the package and all its dependencies:

sudo dpkg -P [package]

For example, purge curl with:

sudo dpkg -P curl

The command removes the package, all its dependencies, and any configuration files from the system.

Option 3: Uninstall Ubuntu Packages with Snap

Snap is a popular software package and deployment system designed for application management on Ubuntu. Uninstalling snaps on Ubuntu is straightforward, as the utility packs all the dependencies into a single package.

To remove snap packages with the snap command, follow the steps below:

1. List all installed snaps with:

snap list
Listing the snaps installed on the system.

2. Note the name of the package to delete.

3. To delete an installed snap, execute:

sudo snap remove [package]

The snap remove command completely deletes the software from the system, including config files and all associated user data. For example, remove the Firefox snap by executing the following command:

sudo snap remove firefox

The output confirms that the package has been removed.

Removing a snap from the system.

Option 4: Uninstall Ubuntu Packages with Flatpak

Flatpak is a software deployment utility that aims to provide a unified method for installing Linux software. Follow the steps below to remove Flatpak packages from the system:

1. Enter this command to list all Flatpak apps and their IDs:

flatpak list --app

2. Note the ID of the app you want to uninstall.

Listing flatpaks available on the system.

3. Uninstall the app by typing:

sudo flatpak uninstall [app-id]

For example, to remove the Firefox flatpak, enter the following command:

sudo flatpak uninstall org.mozilla.firefox
Uninstalling a flatpak.

4. Unused runtime libraries accumulate over time. To delete unused runtimes, use the --unused option:

flatpak uninstall --unused

5. If you wish to delete all Flatpak apps, use:

flatpak uninstall --all

Note: Learn about the differences between Flatpak, Snap, and AppImage.

Option 5: Uninstall Ubuntu Packages with ppa-purge

Third-party repositories allow users to access applications that are unavailable in the default system repositories. The ppa-purge utility provides a way to uninstall all the packages from a single repository and remove the repository itself.

Note: If ppa-purge is unavailable on the system, install it by typing: sudo apt install ppa-purge.

Use the following syntax for the ppa-purge command:

sudo ppa-purge [ppa]

Replace [ppa] with the repository name. For example:

sudo ppa-purge ppa:ubuntu-mozilla-daily/ppa

The output confirms the success of the operation.

Purging a ppa on Ubuntu.

Option 6: Remove Ubuntu Packages with rm

Application binaries are located in multiple locations across the system, e.g., /usr/bin, /usr/sbin, and /usr/local/bin. To manually remove a binary, use the rm command:

sudo rm -rf [path-to-binary]/[binary]

For example, to remove test-app located in /usr/local/bin, type:

sudo rm -rf /usr/local/bin/test-app

Warning: Manually removing packages may result in broken installations and compromise the system's stability.

Option 7: Remove Dependencies with autoremove

Unnecessary dependencies sometimes remain on the system from previous installations. To get rid of unused packages and free up space, run the following:

sudo apt autoremove -y
Removing unused packages with the apt autoremove command.

The command removes all orphaned or unused dependencies.

Uninstall Packages in Ubuntu via GUI

Ubuntu users who prefer managing packages via a graphical interface can use Ubuntu Software Center, the default GUI solution. Another popular option is Synaptic Package Manager, which offers more granular control over packages.

The following sections provide instructions for uninstalling packages in Ubuntu using GUI.

Option 1: Uninstall Packages with Ubuntu Software Manager

The default software manager for Ubuntu GUI users is Ubuntu Software Center. To uninstall a package using this utility, proceed with the following steps:

1. Open Ubuntu Software Center.

The location of the Software Center application in the Ubuntu sidebar.

2. Select the Installed tab.

The Installed section of the Ubuntu Software Center.

3. Scroll down the list of programs and find the one to uninstall.

4. Click the Uninstall button next to the program.

Uninstalling an app in the Ubuntu Software Center.

5. Type the password to confirm and wait for the uninstallation to finish.

Option 2: Use the Synaptic Package Manager

Many Ubuntu users prefer Synaptic Package Manager due to its robust build and feature-rich interface. To uninstall packages using Synaptic, launch the tool and follow the steps below:

1. Select the Status button on the left side of the screen.

2. Choose Installed from the menu options.

The Status section of Synaptic Package Manager.

3. Highlight the application you want to remove from the list of packages.

4. Right-click the application.

5. Select Mark for Removal. Alternatively, select Mark for Complete Removal to delete the standard configuration files along with the software package.

6. Click Apply.

Marking an app for removal in Synaptic.

Conclusion

After reading this article, you should be ready to uninstall or remove packages in Ubuntu. The guide provided detailed instructions for package removal using both the command line and the GUI.

Next, learn how to list all installed packages in Ubuntu.

Was this article helpful?
YesNo
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
How to Install RPM Packages on Ubuntu
March 28, 2024

RPM is a package format used by Red Hat based derivatives like CentOS, RHEL or Fedora. It gets its name from...
Read more
How to List Installed Packages on Ubuntu
March 9, 2022

Having a precise list of installed packages helps system admins maintain, replicate, and reinstall systems...
Read more
How to use APT Package Manager on Ubuntu
May 23, 2024

In Linux, special tools were developed for managing applications. Application software for Linux typically...
Read more
How to Install MySQL on Ubuntu
June 3, 2021

MySQL is an open-source relational database server tool for Linux operating systems. It is widely used in modern web-based technology, and it forms part of...
Read more