Home Package management How To Uninstall A .deb Package On Debian And Ubuntu

How To Uninstall A .deb Package On Debian And Ubuntu

By sk
710 views

If you use a Linux system based on Debian, such as Ubuntu or Linux Mint, you're likely familiar with dpkg tool. It's a command-line tool that allows you to install, remove, and manage individual .deb packages. Sometimes, you might manually install a .deb package to try out a new app or fix a problem. For instance, I've installed beta versions of Oracle VirtualBox using dpkg. But what do you do when you no longer need that package? In this blog post, I'll show you how to uninstall a .deb package that you installed with the dpkg command in Debian, Ubuntu and its derivatives such as Linux Mint, Pop!_OS, Elementary OS, and Zorin OS etc.

To remove a .deb package from a Debian-based system, you can use the dpkg or apt or apt-get command. First, we will see how to remove a .deb package using dpkg command.

Method 1: Uninstall .deb Package using dpkg

1.List Installed Packages:

First, you can list the installed packages to confirm the package name.

dpkg -l | grep <package_name>

Example:

dpkg -l | grep virtualbox-7.1

Sample Output:

ii  virtualbox-7.1                                          7.1.0-164728~Debian~bookworm                         amd64        Oracle VirtualBox

2. Uninstall the Package:

Now, use the dpkg command to uninstall the .deb package.

sudo dpkg -r <package_name>
  • -r stands for "remove" and will uninstall the package but leave its configuration files intact.

3. Purge the Package (Optional):

If you want to remove the package along with its configuration files, use the -P option.

sudo dpkg -P <package_name>

Method 2: Remove a .deb Package using apt

1. Remove the Package:

To remove a .deb package, use the apt command like below.

sudo apt remove <package_name>

Example:

sudo apt remove virtualbox-7.1

This command will remove the VirtualBox v7.1 package but leave its configuration files intact.

2. Purge the Package (Optional):

If you want to remove the package along with its configuration files, use the purge option.

sudo apt purge <package_name>

Method 3: Uninstall a .deb package using apt-get

1. Uninstall the Package:

To uninstall a package, use the apt-get command like below:.

sudo apt-get remove <package_name>

Example:

sudo apt-get remove virtualbox-7.1

2. Purge the Package (Optional):

If you want to remove the package along with its configuration files, use the purge option.

sudo apt-get purge <package_name>

apt vs apt-get

The apt and apt-get commands are both package management tools used in Debian-based Linux distributions. They serve similar purposes but have some differences in terms of user interface and functionality.

apt is a newer, simplified command for managing packages, designed for everyday use, combining features of apt-get and apt-cache. apt-get is the older, more detailed tool, better suited for scripting and advanced tasks.

You can use any one or both for managing packages in DEB-based systems. It depends on your preference.

Summary

  • dpkg -r <package_name>: Uninstalls the package but keeps configuration files.
  • dpkg -P <package_name>: Uninstalls the package and removes configuration files.
  • apt remove <package_name>: Uninstalls the package but keeps configuration files.
  • apt purge <package_name>: Uninstalls the package and removes configuration files.
  • apt-get remove <package_name>: Uninstalls the package but keeps configuration files.
  • apt-get purge <package_name>: Uninstalls the package and removes configuration files.

Choose the method that best suits your needs.

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More