FUNDAMENTALS A Complete Guide for Beginners
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
Now you can remove the vlc package.
➌ Write the code to remove the vlc package with its unnecessary dependencies:
sudo dpkg -r vlc
- -r: Command option to remove package file.
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
- -P: Command option to purge a package.
- – -purge: Command option to purge a package.
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
- – -no-debsig: Command option to disable package signature verification.
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
- – -force-depends: Command option to bypass the dependency check and remove vlc package forcibly without dependencies.
Finally, the vlc package has been removed after resolving the dependency issues.
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
- How to Uninstall RPM in Linux [2 Simple Cases]
- How to Uninstall a YUM Package [2 User-Friendly Cases]
- How to Remove a Specific Version Using YUM [2 Easy Methods]
- How to Force Remove a Package Without Dependencies Using Yum [2 Methods]
- How to Remove and Purge a Package Using apt-get [4 Methods]
- How to Remove Apt-key in Linux [3 Practical Methods]
<< Go Back to Uninstall Packages in Linux | Package Management in Linux | Learn Linux Basics