How to Fix Broken Packages on Ubuntu 16.04 / Debian 9

How to Fix Broken Packages on Ubuntu 16.04 / Debian 9. When a Linux user or sysadmin performs package management on Ubuntu / Debian most of them preferred apt-get or dpkg as a package management utility to install and upgrade the new packages. This types of errors occurs periodically where installation is done in mean time when user faces broken packages issues due to various reasons including improper package management, incorrect packages installation, incorrect installation of packages from source files, installation of unwanted packages, installation of in-compatible packages, etc. This tutorial explains how to fix those broken packages in mean time by integrating given tips and tricks on your Ubuntu / Debian distribution.

Pre-Steps-1 (Remove the apt-get package locks)
$ sudo rm -rf /var/lib/apt/lists/lock /var/cache/apt/archives/lock /var/lib/dpkg/lock
Pre-Steps-2 (Restart your Ubuntu / Debian distribution)
$ sudo init 6
Step-1 (Remove the repository cache using apt-get package manager)
$ sudo apt-get clean all
Step-2 (Update the repository cache using given commands)
$ sudo apt-get update
Step-3 (Upgrade the packages to upgrade the distributions)
$ sudo apt-get upgrade
Step-4 (Now run distribution upgrade command to update the packages)
$ sudo apt-get dist-upgrade
Step-5 (Find broken packages list to fix)
$ sudo dpkg -l | grep ^..r

Note: After the above command it shows the list of broken packages and you need to note all the broken packages name to remove it one by one using given commands.

Step-6 (Force removal of broken packages using given commands)
$ sudo apt-get remove package-name

Note: You must change the package-name with the broken-packages-name that you have noted earlier.If above commands won’t works then given command is necessary to remove it forcefully.

$ sudo dpkg --force-all --remove package-name

Conclusion

Finally you have fixed above broken packages using above apt-get and dpkg package mangers using above commands. Above fix is useful to fix those broken packages and If you have some issues then you need to use the comment section below for more help and support.

Hot Right Now

Related Post

COMMENTS