How to Find and Fix Broken Packages on Linux

How to Find and Fix Broken Packages on Linux

Broken packages need repairing or the software won’t run. Here’s how to find the broken packages and fix them in Linux.


Package managers in Linux allow you to control the installation and removal of packages. In addition to that, package managers also help you in finding broken packages on your system and reinstalling them to fix various issues associated with Linux packages.

If you are unaware of which commands to use in order to find and fix broken packages in Linux, then this guide is for you. We will discuss broken packages in brief detail, how you can check if your system contains broken packages, and how to reinstall them properly.

What Are Broken Packages?

When you install a new package in Linux, your system’s package manager is in charge of the whole installation process. These package managers have built-in methods to handle exceptions and errors. But sometimes, in case of unexpected issues, the installation halts and the complete package isn’t installed. Such packages are called broken packages in Linux.

Package managers like APT do not allow the further installation of packages if it finds a broken package on the system. In such a situation, repairing the broken package is the only choice to go for.

How to Find and Fix Broken Packages

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

Reinstalling Broken Packages on Debian

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

Related: How to Install Software on Linux: Package Formats Explained

Fix Broken Packages on 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 capable of handling most of the issues including failed installations. But sometimes, various problems occur that can only be solved intuitively. The solution to fixing broken packages comprises several steps—identifying the broken package, reinstalling it, and updating the system’s package list.

There are countless Linux distributions available on the internet that are worth trying, but deep down, each one of them has a similar foundation. Desktop environments set each distribution apart by providing a unique user experience. Choosing an ideal desktop environment that suits your taste should be your priority if you have finally decided to go ahead with Linux.

The 12 Best Linux Desktop Environments

Choosing a Linux desktop environment can be difficult. Here are the best Linux desktop environments to consider.

Read Next

About The Author

Original Link

Leave a Comment

Your email address will not be published.