Site icon NetworkHunt

How to uninstall packages with APT in Debian Linux

How to uninstall packages with APT in Linux

APT (Advanced Packaging Tool) is a powerful package manager designed for Debian-based Linux systems, allowing users to manage software efficiently. APT provides multiple ways to uninstall packages with APT in Debian Linux, depending on whether you want to remove only the software or delete its configuration files. Here we will explore how to uninstall packages with APT in Linux.

This guide covers step-by-step methods to uninstall packages using APT commands in Debian Linux, clean up system resources, and resolve issues like broken dependencies. Whether you’re a beginner or an experienced Linux user, these methods will help you maintain a clean and optimized system. By following this guide, you will understand how to uninstall packages with APT in Linux properly.


Table of Contents
  1. What is APT?
  2. List of Installed Packages
  3. Uninstalling Packages Using APT
  4. Cleaning Up After Uninstallation
  5. Fixing Broken Dependencies

What is apt?

Advanced Packaging Tool (apt) is a package manager for Debian-based systems. It is used for installing, updating, and removing programs from a system. To learn more about apt and Package Management click here. The apt suite provides several commands to help you manage your system and understand how to uninstall packages with APT in Linux.

When you want to uninstall a program, there are a few ways to do it with apt, depending on whether you want to remove the program entirely, or just remove the program without its configuration files. Understanding the options will guide you in how to uninstall packages with APT in Linux effectively.


List of Installed Packages-

Before we remove any package from our system, it might be helpful to check what packages are installed on the system. To list the packages, and install them on the system use the command below:

$> sudo apt list --installed

Uninstalling Packages Using Apt-

Method 1:  (Using apt remove command)

The apt remove command is used to remove (uninstall) a package from the system, but it doesn’t delete the configuration files associated with the package. This method is useful for those users who may want to reinstall the package in the future. Thus, this method allows them to reinstall the package with the same configurations as when it was deleted. This illustrates one way of how to uninstall packages with APT in Linux without losing configurations.

To uninstall a package, use the command below-

 $> sudo apt remove <PACKAGE_NAME>
Method 2: (Using apt purge command)

The apt purge command is used to uninstall a package from the system with the configuration files associated with the package. This method is useful for those users who want to uninstall the package completely from the system. This method provides a more thorough approach on how to uninstall packages with APT in Linux.

To uninstall a package, use the command below-

 $> sudo apt purge <PACKAGE_NAME>

Cleaning Up After Uninstallation-

Once you uninstall a package it is a good practice to clean up the cache files and installed dependencies that are no longer required.

The apt clean command is used to remove downloaded package files from your system’s local cache i.e. the .deb files stored in /var/cache/apt/archives that are no longer needed after installation or upgrade. This command only removes cache files not the installed packages.

To clean the package cache, use the command below-
$> sudo apt clean

The apt autoremove command is used to automatically remove dependencies that were installed with a package but are no longer required by any installed package. These dependencies can accumulate over time, taking up unnecessary disk space. This method ensures a tidy system when you learn how to uninstall packages with APT in Linux.

To delete unnecessary dependencies,  use the command below-
$> sudo apt autoremove

Fix Broken Dependencies-

Sometimes, uninstalling a package may end up breaking the dependencies of another package. To fix this issue use the command below-

$> sudo apt -f install

The sudo apt -f install  is a command used to fix broken dependencies a system. If any package has broken dependencies, running this command will attempt to correct those issues by installing the missing dependencies or fixing any broken packages.


Exit mobile version