How to find and fix Broken Packages on any Linux

On Linux, a package manager helps with your ability to install software to make use of your operating system. In as much as they are built to be yearning perfection; they may result in broken packages.

On Linux, a package manager helps with your ability to install software to make use of your operating system. In as much as they are built to be yearning perfection; they sometimes hit a hitch which results in a broken package. Package managers also helps with finding broken packages on your system and as well assist your with removing and reinstalling them to fix various issues associated with Linux packages as and when you run into any.

What’s a Broken Packages?

Broken package arise when the package managers built-in instructions to handle exceptions and errors fail for various reasons and an installation process stops before it could complete. Package managers like APT does not allow installation of packages if it detects a broken package on the system. When this happens, repairing the broken package is your only comfort.

The Find and Fix process

All package managers handles different types of packages. For example, DNF and YUM work with the Red Hat Package Manager (RPM) to download and install RPM packages whiles, APT acts as a front-end wrapper for the base dpkg software on Debian-based distributions.

The Reinstalling process for Debian based distros

APT is the default package manager that comes preinstalled on every Debian-based distribution. Apart from APT, Debian and Ubuntu users can download and install packages manually using dpkg as well. To fix broken packages on Debian-based distributions using APT:

  1. Open the terminal by pressing Ctrl + Alt + T on your keyboard and enter: sudo apt --fix-missing update
  2. Update your system’s package list from the available sources: sudo apt update
  3. Now, force the installation of the broken packages using the -f flag. APT will automatically search for broken packages on your system and reinstall them from the official repository. sudo apt install -f

If the aforementioned steps do not work for you, then you can try to solve the issue using dpkg.

  1. Force dpkg to reconfigure all the pending packages that are already unpacked but need to undergo configuration. The -a flag in the command stands for All. sudo dpkg --configure -a
  2. Pipe grep with dpkg to get a list of all the packages marked as Required by dpkg. sudo dpkg -l | grep ^..r
  3. Use the –remove flag to delete all the broken packages. sudo dpkg --remove --force-remove-reinstreq
  4. Clean up the package cache and install scripts using apt clean. sudo apt clean
  5. Now, update your system’s package lists using the following command: sudo apt update

The Reinstalling process for Fedora/CentOS and RHEL

Although YUM and DNF are great when it comes to managing broken packages automatically, sometimes problems do arise as there are thousands of packages installed on a Linux system. In such situations, you can use RPM (the base package manager for Fedora and CentOS) to fix such issues quickly.

  1. Verify all the packages on your system using the -V flag. sudo rpm -Va
  2. You will see a long list containing all the installed packages on your system.
  3. Reinstall the package that you think might be causing the broken package issue. sudo dnf --refresh reinstall packagename

The above steps are highly inconvenient—identifying which package is causing the problem from a list of hundreds is tiresome. Although RPM is a powerful package manager and you will rarely run into such issues, knowing how to fix these problems is still important in case you bump into a similar situation in the near future.

Managing Packages on Linux Distributions

Package managers on Linux are equipped to handle most of the issues of installation, including failed installations. However sometimes, various problems occur that can only be solved intuitively. The solution to fixing broken packages comprises several steps;

  1. identifying the broken package
  2. reinstalling it and
  3. updating the system’s package list.

Linux distributions is ever-growing on the internet yet, each one of them has a similar foundation. Each environments set each distribution apart by providing some unique user experience. An environment that suits your requirements should be your priority if you have decided to go Linux. Whiles at it, we have Linux tips every geek should know, you should check it out.

More Information

Last updated on November 30th, 2022


Inspiring readers to expound the possibilities of the unfolding World

Enable referrer and click cookie to search for 1234raz0r 0114653a731bf521 [***************] 2.7.28