How to Fix Broken Packages in Linux

 While Linux comes with power package managers such as Apt and DNF, things can still go wrong. If any package install fails or goes wrong, you are left to pick up the broken pieces of that package. However, the package managers are always there to help you fix such broken packages to get your system to work again. Unfortunately, that doesn’t happen automatically, and you have to run some commands to let the package managers do what they can. So, here are a few tips, tricks, and techniques that you might need to know to run a broken package again. Read on!


How to Fix The Broken Packages

If your system has broken packages or missing dependencies, then you can use the flags in Apt. Follow the steps below to do so: 

Step 1: Start by updating your system to download newer versions of packages, if any. Use the command below:

sudo apt update –fix-missing

Step 2: Run Apt and check for any broken packages or missing dependencies. Run the command below to install and repair the required packages.

sudo apt install -f

It’s the dpkg that controls the configuration process, and this is where the error can occur during configuration. Therefore, forcing dpkg to reconfigure any missing or broken package might help fix it. Run the following command do so:

sudo dpkg –configure -a

In case the above method didn’t help solve the issue, there is another way possible. You can list the packages that are marked by dpkg to reinstall. Run the command below:

sudo dpkg -l | grep ^..r

This will open up a list of all the packages that are creating a problem. If you find anything here that shouldn’t be, then run the command below to force-remove it.

sudo dpkg –remove –force-remove –reinstreq

Once done, clean up the dpkg with Apt by using the commands below:

sudo apt clean

sudo apt update

This action will enable the Apt to function again, if not bring you the packages that broke.

Permanent DPKG Lock

In case you are facing problems getting into dpkg with the error message that says, “another application is already running,” every time you try to enter dkpg or Apt. In that case, you need to delete the file that isn’t letting you access the Apt. Sometimes the lock files manage to stay in place even after you uninstall a process, preventing and derailing the files when you try to remove them. So, you need to fetch these files and remove them for good. Use the commands below to do so:

sudo rm /var/lib/apt/lists/lock

sudo rm /var/cache/apt/archives/lock

How to Fix the Broken Packages in Fedora/CentOS/RHEL

Rarely, but files get jumbled in packages, and that is when you need to use Fedora/CentOS/RHEL to fix the broken packages. Below is the command for it:

sudo rpm -Va

This will bring up the list of all the files running on your system. The downside is that you need to scan the huge list to find something that might be causing you trouble. When you do find one, run the command below to reinstall it:

sudo dnf –refresh reinstall PACKAGE_NAME

We hope that one of the fixes mentioned above helped you solve the problem, and you are now able to work on your Linux as you regularly do. It is always a good idea to take back the process of facing the problem to where it initially was, instead of adding more things without knowing its ins and outs.

Mia Watson is an avid technical blogger, a magazine contributor, a publisher of guides at Blogs Book, and a professional cyber security analyst. Through her writing, she aims to educate people about the dangers and threats lurking in the digital world. Visit My Site, webgeeks.uk.com

Source: Broken Packages in Linux

Comments

Popular posts from this blog

6 Instagram photo editing trends in 2020

Here’s How One Can Force Outlook to Spellcheck the Emails

5 rules before you buy insurance for your electronic device