Skip to content
Related Articles

Related Articles

How to Uninstall Packages With Apt Package Manager in Linux

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 22 Jun, 2022

The apt command is a sophisticated command-line tool that interacts with Ubuntu’s Advanced Packaging Tool (APT) to execute tasks including installing new software packages, updating the package list index, and even upgrading the whole Ubuntu system. Along with this, we can uninstall or remove the downloaded packages from the system. So in this article, we will go through the steps of uninstalling the packages from the Ubuntu system.  

These are some following methods in Linux to delete packages using apt-package manager:

  • Uninstall the program using apt purge
  • Uninstall the program using the apt remove
  • Remove broken packages or packages which weren’t fully installed

Let’s go through both methods one by one.

Get the List of Installed Packages

sudo apt list

This command will show you a list of all the packages you’ve installed. You can skip this step if you already know the name of your package.

apt list

 

Method 1: Uninstall the program using apt purge:

sudo apt purge <package name>

Using apt to delete packages is the same as using apt-get to install it. 

For this article, we will be going to remove firefox along with its configuration.

 

Method 2: Uninstall the program using apt remove:

sudo apt remove <package name>

 

To avoid confirmation, you can alternatively use the “-y” option,

sudo apt remove -y <package name>

 

For Post uninstall clean Up

sudo apt clean && sudo apt autoremove

 

  • clean: Removes the cache of programs that are older than the one that was installed.
  • autoremove: Removes files that are no longer needed, such as dependencies.

Method 3: Remove broken packages or packages which weren’t fully installed:

sudo apt clean && sudo apt autoremove
sudo apt -f install
sudo dpkg --configure -a
remove_broken_packages_cmds

 

  • -f install: Fix any broken dependencies and any potential package corruption issues.
  • dpkg –configure -a: Reconfigure an unpacked package and “-a” means all unpacked but configured packages are configured.

What’s the difference between ‘remove‘ and ‘purge‘?

You must be thinking that what’s the difference between the remove command and the purge command. On executing the “remove” command it will keep the package’s configuration files after the uninstallation while the “purge” command will delete the package’s configuration files after the uninstallation.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!