How to Remove Package and Dependencies Using “dpkg” [4 Cases]

dpkg refers to the ‘Debian Package’ which is a low-level package manager used in Debian-based Linux derivatives like Ubuntu, Linux Mint, Kali Linux, etc. This package management tool is able to do multiple package-related operations including installing, removing, or managing packages. Moreover, dependencies of the packages can also be maintained by this dpkg manager. In this article, I will show you the detailed procedure about how to remove a package and its dependencies with the dpkg command. Let’s get started.

4 Practical Cases to Remove a Package and Dependencies With “dpkg”

Removing a package with dpkg will remove the package as well as unused dependencies. However, if you wish to have a complete removal, dpkg can be used to purge the package. Additionally, you can remove a package remaining its dependencies intact. Furthermore, forcefully removing a package without dependencies can also be achieved with this package manager. Check the following cases carefully to accomplish the tasks.

Case 01: Removing a Package and Unnecessary Dependencies Using “dpkg”

dpkg has the potential to remove a package with dependencies that are no longer required. It is a default package manager of the Debian-based Linux distros. Therefore, if you wish to remove only a package you can follow the below steps:

Steps to Follow >

➊ Open the Ubuntu terminal.

➋ Find the vlc package by writing this code:

sudo dpkg -l | grep vlc
EXPLANATION
  • sudo: Permits administrative privileges.
  • dpkg: Debian package manager to install, uninstall, and manage software packages.
  • -l: Command option to list packages in Debian-based Linux.
  • |: Takes the output of one command to the input of another.
  • grep: Searches text patterns.
  • vlc: Package name.

finding vlc package using dpkg

Now you can remove the vlc package.

➌ Write the code to remove the vlc package with its unnecessary dependencies:

sudo dpkg -r vlc
EXPLANATION
  • -r: Command option to remove package file.

removing vlc with dpkg package manager

The vlc package with its unrequired dependencies has been removed. However, this command is not enough to remove the package with all dependencies, so follow the next case.

Case 02: Removing a Package With Dependencies and Config Files Using “dpkg”

If you want to get complete uninstallation of a package, purging the package with dpkg is the most feasible way. Purging a package means removing not only a package but also its dependencies and configuration files. Hence, to purge a package, strictly follow the steps below:

Steps to Follow >

➊ Run the following command to remove vlc with dependencies and config files:

sudo dpkg -P vlc

OR,

sudo dpkg --purge vlc
EXPLANATION
  • -P: Command option to purge a package.
  • – -purge: Command option to purge a package.

removing vlc with dependencies and config files using dpkg

After running this command line, all the config files and dependencies of vlc package will be deleted.

Case 03: Removing a Package Keeping Dependencies Intact Using “dpkg”

Sometimes keeping dependencies intact is crucial. In that case, you can remove a package without dependencies with dpkg package manager by disabling package signature verification. Here, I will describe the step-by-step procedure to finish this task. Check the details:

Steps to Follow >

➊ Open the Ubuntu terminal.

➋ Now, write the code to remove the vlc package without affecting its dependencies:

sudo dpkg --no-debsig -r vlc
EXPLANATION
  • – -no-debsig: Command option to disable package signature verification.

removing vlc package ignoring dependency check

After running the command, the vlc package will be removed but the dependencies will remain in the Linux system.

Case 04: Removing a Package Forcefully Without Dependencies Using “dpkg”

Forcefully removing a package is the last option for package uninstallation if any issues arise during package removal. This process will not ask for permission to remove a package and dependencies. Rather it automatically removes the package by resolving the created issues. Check the steps below:

Steps to Follow >

➊ Open the Ubuntu terminal.

➋ Run the following command to remove vlc forcefully by resolving dependency problems:

sudo dpkg --remove --force-depends vlc
EXPLANATION
  • – -force-depends: Command option to bypass the dependency check and remove vlc package forcibly without dependencies.

forcefully removing vlc without dependency

Finally, the vlc package has been removed after resolving the dependency issues.

Note: However, it is not recommended to remove any package forcefully as it may make the system unstable. So be cautious before using this command.

Conclusion

I believe this article assists you in removing a package and dependencies with dpkg package manager. This package management system only works in Debian-based derivatives. Here, I have explained 4 practical cases to remove the vlc package and its dependencies. Similarly, you can remove any package you want by following the exact procedure. Check every case carefully and perform whichever you prefer. Best wishes.

People Also Ask

How do I remove apt package and dependencies?

To remove the apt package and dependencies, run this command after opening a Ubuntu terminal: sudo apt autoremove.

How to remove packages with unmet dependencies?

To remove packages with unmet dependencies, first see the unmet dependencies using sudo dpkg --audit command. Then run the sudo dpkg --remove--force-all <package_name> to remove the package with unmet dependencies.

What is dpkg vs apt?

dpkg is the older version package manager whereas apt is the latest one. Also, apt offers additional features like automatic handling of dependencies that dpkg doesn’t offer.

How to reconfigure dpkg?

To reconfigure packages, you can use dpgk package manager. Run this command sudo dpkg-reconfigure -f <package_name> to force a reconfiguration of some broken packages.


Related Articles


<< Go Back to Uninstall Packages in Linux | Package Management in Linux | Learn Linux Basics

4.4/5 - (14 votes)
Mitu Akter Mou

Hello, This is Mitu Akter Mou, currently working as a Linux Content Developer Executive at SOFTEKO for the Linuxsimply project. I hold a bachelor's degree in Biomedical Engineering from Khulna University of Engineering & Technology (KUET). Experiencing new stuff and gathering insights from them seems very happening to me. My goal here is to simplify the life of Linux users by making creative articles, blogs, and video content for all of them. Read Full Bio

Leave a Comment