How to Uninstall a .deb Installed With dpkg in Linux?

In Linux, the “dpkg” is the package manager used to manage the Debian files on Debian based systems, i.e., Debian, Ubuntu, Linux Mint, Kali. The recent releases of Debian/Ubuntu do offer the apt support to manage the Debian package files instead of “dpkg”. Thus, a package installed with “dpkg” can be removed using the “dpkg” and “apt”. 

This article will illustrate the multiple methods to uninstall a “.deb” file installed with the “dpkg” with the following outline: 

Method 1: Uninstall a “.deb” Using apt

The Advanced Package Tool (APT) is a package management system used by these Linux distributions to manage software installation, updates, and removal.

To uninstall a .deb package using apt in Linux, follow these steps:

Step 1: Identify the Package

Identify the name of the package to uninstall. For this, specify the package name “teamviewer” to uninstall from the system:

$ dpkg -l | grep teamviewer

This command will list all the packages that match the specified name.

Step 2: Uninstall the Package

Once the package is identified, uninstall using the apt command. Specify the “teamviewer” in the following command:

$ sudo apt remove teamviewer

This command removes the “teamviewer” package from the system.

Step 3: Remove the Package Completely

To completely remove the package and its associated configuration files, use the “purge” option instead of the remove option by specifying the package name as “teamviewer”:

$ sudo apt purge teamviewer

This command removes the package along with any configuration files associated with the package.

Step 4: Remove Associated Dependencies

The “autoremove” command removes any packages that were installed as dependencies. For instance, specify the package name “teamviewer” in the below command: 

$ sudo apt autoremove teamviewer

It removes the “teamviewer” package with dependencies on the system. 

Method 2: Uninstall a .deb Installed Package with dpkg 

The step-by-step procedure to uninstall the .deb package with the dpkg is mentioned below:

Step 1: Check Installed .deb Package in Linux

Before uninstalling any package, it is a good approach to check the installed .deb package in Linux. For instance, the “dpkg” command is utilized with the “list” option as below: 

$ dpkg --list

In the list of installed Debian packages, users can select one of them according to their requirements. In our case, select the “teamviewer” installed application to uninstall from the operating system.

Step 2: Uninstall a .deb Installed Package

To remove the installed package, users can utilize the “dpkg” command by specifying the name of the package with the “remove” option. For instance, uninstall the “teamviewer” package from the system:

$ sudo dpkg --remove teamviewer

The output shows the “teamviewer” package and all its configuration files have been removed from the system.

Step 3: Remove the Package Completely

To completely remove the package and its associated configuration files, use the “purge” option instead of the remove option by specifying the package name as “teamviewer”:

$ sudo dpkg --purge teamviewer

The “teamviewer” package along with any configuration files associated with the package has been removed.

Note: The dpkg command is used to install, remove, and manage individual package files, but it does not have an “autoremove” option.

Step  4: Verify the Uninstallation of .deb Package

Users can verify the uninstalled package by mentioning the name of the package such as “teamviewer”:

$ teamviewer

The output shows that the “teamviewer” package is not available in the operating system.

Conclusion

To uninstall a .deb installed package with dpkg, use the “sudo apt -remove <package_name>” and “sudo dpkg -remove <package_name>” commands in Linux. These commands specify the “<package_name>” to remove from the system. This guide has provided all possible methods to uninstall the .deb installed package with the ”apt” and “dpkg” in Linux.