Subscribe to our RSS feed to get alerted every time SUBSCRIBE!

How to Fix Broken Packages on Ubuntu / Debian

Finally When a Linux user or sysadmin performs package management on Linux system. Most of them preferred apt or 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.Broken packages caused the package manager apt fail to work. This issue makes apt inoperable and accessible. This tutorial provides guidance against this kind of issue.

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 Linux distribution.

1. First of all Remove the apt-get package locks.

 sudo rm -rf /var/lib/apt/lists/lock /var/cache/apt/archives/lock /var/lib/dpkg/lock

2. Secondly Restart your Ubuntu / Debian distribution.

 sudo systemctl reboot

3. Then Remove the repository cache using apt-get package manager.

 sudo apt clean all

4. After that Update the repository cache using given commands.

 sudo apt update

5. Also Upgrade the packages to upgrade the distributions.

 sudo apt upgrade

6. Now run distribution upgrade command to update the packages.

 sudo apt dist-upgrade

7. After that 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.

8. Force removal of broken packages using given commands.

 sudo apt 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

9. Finally Install the remaining dependencies caused due to package installer dpkg.

 sudo apt install -f

Congratulation now you have fixed the broken package issue on Linux.