How to Uninstall Debian Package

Installing Debian packages is one of the easiest parts of using Linux but when we talk about the uninstallation process, things are quite rough on this side as you get multiple options to remove packages such as dpkg to uninstall packages, purging, and GUI facilities too.

So we are going to show you an in-depth tutorial on how you can use each tool available to use for uninstalling Debian packages with multiple choices and options. So lets’ start our process by getting a list of installed packages.

List Installed Packages Using Dpkg

We are going to use the dpkg –list command to show all the installed packages. This is an essential step because often we don’t know the full name of the package that we want to remove and using the wrong name, we get an error saying “Unable to locate package

But if you know the exact name of the package, you can skip this step.

Open your Terminal and use the following command to list all the installed packages:

 dpkg –list 

1. dpkg --list

Scroll down and you will find your desired package which you want to remove. In our case it’s TeamViewer. We will be using the same package for all the removal demonstrations.

2. showing TeamViewer

Uninstall Packages Using apt-get

You can remove packages using apt-get but you will have to use some parameters which we are going to discuss further. As we are required to remove packages, we will be using two parameters “remove” and “–purge”.

The first parameter “remove” will remove packages but keep all the configuration files but we also want to remove configuration files and this is the reason why we have used the second parameter “–purge” which will remove configuration files too.

Use the following command to remove required packages using apt-get:

 sudo apt-get –purge remove teamviewer 

2.1 sudo apt-get --purge remove teamviewer

As you can see, it asks our permission to remove TeamViewer but if you want to automate this process that won’t ask for your password, you can use -y at the end of the command.

 sudo apt-get –purge remove teamviewer -y 

2.2 sudo apt-get --purge remove teamviewer -y

If you want to uninstall packages without using “remove” parameters, you can easily do it by just using the ” –purge” parameter. This will remove binaries and configuration files related to our desired package, in our case it’s TeamViewer.

You can follow the given command to use only the “–remove” parameter.

 sudo apt-get purge teamviewer 

2.3 sudo apt-get purge teamviewer

There is another where we only use remove which will only delete packages keeping configuration files and data. If you are someone who wants to remove only package keeping files safe, you can follow the given command:

 sudo apt-get remove temviewer 

2.4 sudo apt-get remove temviewer

Uninstall Packages Using Dpkg

Linux has always been about choice and you get multiple ways to perform almost any task you desire. As we have already discussed one way to uninstall packages using apt-get and you also have another way to uninstall packages using dpkg.

We can easily remove packages using the following command where we have just interchanged apt-get with dpkg:

 sudo dpkg –remove teamviewer 

3. sudo dpkg --remove teamviewer

You can also use -r instead of –remove as they are both the same. It will look similar to the following command:

 sudo dpkg -r teamviewer 

3.1 sudo dpkg -r teamviewer

Uninstall Broken Packages

As Linux user, we often face a situation where our package is not installed properly which cause malfunctioning and we often fail to locate that package as it is not installed properly.

But you can easily overcome all the issues which you might be facing due to broken packages by given commands:

 sudo apt-get clean && sudo apt-get autoremove 

This command will remove the old cache of programs that are older than the current version installed and also remove unnecessary files including dependencies that are no longer required.

4. sudo apt-get clean && sudo apt-get autoremove

 sudo apt-get -f install 

This command will fix all the broken dependencies and will correct package corruption problems.

4.1 sudo apt-get -f install

 sudo dpkg –configure -a 

This command will solve the remaining problems.

4.2 sudo dpkg --configure -a

Uninstall Packages Using Apt

According to many users apt and apt-get are the same but they are not. They may work in similar ways with the similar syntax but still, they are different from their core. For example, we can list all the installed software such as we have previously done with dpkg.

Use the following command to list installed packages using apt:

 apt list –installed 

5. apt list --installed

To remove the package without including its configuration files and dependencies, use the following command:

 sudo apt remove teamviewer 

5.1 sudo apt remove teamviewer

If you want to remove binaries, configuration files, data, and dependencies, use the following command:

 sudo apt purge –auto-remove teamviewer 

5.2 sudo apt purge --auto-remove teamviewer

It would ask for your permission and you can remove this part similarly we have done previously by adding -y at the end of the command.

 sudo apt purge –auto-remove teamviewer -y 

5.3 sudo apt purge --auto-remove teamviewer -y

Uninstall Packages Using GUI

Yes, you can remove packages using GUI which won’t involve any complex tasks. We are going to show you two ways by which you can remove installed packages from Debian-based distributions. So let’s start our process with the easiest one.

Uninstall Packages Using Software Center

This method can be only applicable if you have installed any software and does not apply to all Debian packages such as libraries and dependencies.

Click on Activities located in lop left corner and type software. Hit Enter on the first result.

6. searching software centre

Click on Installed and scroll down till you find your desired package that you want to remove. Once you find that package, click on remove

6.1 found TeamViewer on Software centre

You will be asked again whether you want to remove it or not. Click on remove and it will ask for your password. Enter your password and it will remove that package.

6.2 click on remove

Uninstall Packages Using Synaptic

This is considered the best tool to manage your applications using GUI. Unlike the software center, where you can not remove dependencies, you can easily remove them using Synaptic. In Debian it is pre-installed but if you have removed it, you can install it by the given command:

 sudo apt install synaptic 

7. sudo apt install synaptic

Once you install Synaptic, click on Activities and type Synaptic. Hit Enter on the first result and it will open Synaptic.

7.1 searching Synaptic

Click on the Search button and type the desired package that you want to remove. Hit Enter and it will show similar results.

7.2 searching teamviewer in synaptic

We have to locate the installed package which will have green color filled in the checkbox. Right-click on the package and select the option named “Mark for complete removal“.

7.3 mark for complete removal

Click on the apply button and it will bring a list of all packages. Click on Apply again to remove.

7.4 click on apply

It will show you the process of package removal.

7.5 showing packages are being removed

Frequently asked questions related to Debian package removal

How do I uninstall a program on Debian?

You can use this command: sudo apt remove <package name> to remove the required package from Debian which will disclude the configuration file and data. If you want to remove a package with its dependencies, use this command: sudo apt purge –auto-remove <package name>

How do I purge a Debian package?

There is a specific way to purge a Debian package that will remove configuration files and binaries related to the package. Use this command to purge a package from Debian: sudo apt purge <package name>

How do I completely remove a package in Linux?

If you want to remove the package completely which includes dependencies, data, configuration files, and binaries. Use this command to remove the package completely from Linux: sudo apt purge –auto-remove <package name>

Related Posts:

Which method do you prefer the most for package removal?

There are multiple ways by which you can uninstall packages from Debian such as package uninstallation using dpkg, apt-get, apt, and GUI. So we included everything by which you can benefit the most from the package removal process.

Sagar Sharma
Sagar Sharma

Sagar always uses Linux to its core and loves to write the technical side of system administration! While he's not writing, you can always find him exploring new Linux distros!

Articles: 37