Saturday, November 16, 2024
Google search engine
HomeGuest BlogsHow to Uninstall Packages in Ubuntu

How to Uninstall Packages in Ubuntu

Introduction

During software installation, package managers often download additional packages (dependencies). While necessary for the installation, these packages stay on the system, hindering performance and taking up storage space.

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

How To Uninstall Packages in UbuntuHow To Uninstall Packages in Ubuntu

Prerequisites

  • Ubuntu system (this tutorial uses Ubuntu 20.04).
  • A user account with sudo privileges.
  • Access to the terminal.

How to Uninstall Packages in Ubuntu

Ubuntu offers different ways to uninstall packages. Users can remove software using apps available in the graphical user interface (GUI) or through the terminal.

Uninstall Packages in Ubuntu Using the CLI

The primary package managers on Ubuntu are apt, dpkg, and snap. Each utility offers several ways to uninstall unwanted software. The following sections provide in-depth instructions.

Option 1: Uninstall Ubuntu Packages with apt

Ubuntu comes with the apt package manager by default. The utility offers several levels of removing unwanted packages from the system. The apt remove command deletes any specified package:

sudo apt remove [package]

For instance, remove Vim from Ubuntu with:

sudo apt remove vim -y
sudo apt remove vim -y terminal outputsudo apt remove vim -y terminal output

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

However, the apt remove command 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]

This command deletes the software entirely from the system. For instance, delete Vim and config files with:

sudo apt purge vim -y
sudo apt purge vim -y terminal outputsudo apt purge vim -y terminal output

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

sudo apt autoremove -y
sudo apt autoremove -y terminal outputsudo apt autoremove -y terminal output

The command removes all orphaned or unnecessary dependencies.

An apt utility for removing outdated packages’ cache is apt clean. 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 another package manager used in Debian-based systems, such as Ubuntu. To uninstall a Debian package, run:

sudo dpkg -r [package]

For instance, to remove Vim, run:

sudo dpkg -r vim
sudo dpkg -r vim terminal outputsudo dpkg -r vim terminal output

The dpkg package manager also allows users to remove packages and all dependencies with the -P option:

sudo dpkg -P [package]

For example, purge Vim and all dependencies with:

sudo dpkg -P vim
sudo dpkg -P vim terminal outputsudo dpkg -P vim terminal output

The command removes a package and any configuration files from the system.

Option 3: Uninstall Ubuntu Packages with snap

Although newer than apt, snap is a popular software package and deployment system. Uninstalling snap packages on Ubuntu is straightforward, as snap packs all the dependencies into a single package. This means that snap remove deletes the software entirely from the system, including config files and all associated user data.

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

1. List all installed snaps with:

snap list
snap list terminal outputsnap list terminal output

2. Note the name of the package to delete.

3. To delete an installed snap, execute:

sudo snap remove [package]

For example, remove FFmpeg with:

sudo snap remove ffmpeg
sudo snap remove ffmpeg terminal outputsudo snap remove ffmpeg terminal output

The output confirms that the package is removed.

Option 4: Uninstall Ubuntu Packages with Flatpack

To uninstall Flatpack packages:

1. List all apps and their ID with:

flatpak list --app

2. Copy-paste the ID of the app you want to uninstall.

3. Uninstall an app using:

flatpak uninstall [app_id]

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

flatpak uninstall --unused

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

flatpak uninstall --all

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

Uninstall Packages in Ubuntu Using the GUI

Ubuntu users who prefer managing packages in a GUI have two ways to uninstall software. The Ubuntu Software Center is the standard package manager, but there is also an alternative.

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, take the following steps:

1. Open Ubuntu Software Center.

Open Ubuntu Software CenterOpen Ubuntu Software Center

2. Select the Installed tab.

Ubuntu Software Center installed tabUbuntu Software Center installed tab

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

4. Click the Uninstall button next to the program.

Ubuntu Software Center Uninstall buttonUbuntu Software Center Uninstall button

Option 2: Use the Synaptic Package Manager

While not as commonly used anymore, the Synaptic Package Manager is still the preferred package manager among certain Ubuntu users due to its robust build.

To uninstall packages using Synaptic:

1. Start by launching Synaptic.

2. From the menu on the left select Status > Installed.

Synaptic status InstalledSynaptic status Installed

3. Highlight the application you want to remove.

4. Right-click the app.

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

Synaptic Mark for RemovalSynaptic Mark for Removal

6. Click Apply.

Conclusion

Now you have a good understanding of several ways to remove packages on Ubuntu Linux. Next, learn how to list all installed packages in Ubuntu.

Was this article helpful?
YesNo

RELATED ARTICLES

Most Popular

Recent Comments