Reinstall or fix broken packages in Linux Ubuntu 15.04 or Ubuntu 14.04. Ubuntu Terminal Commands (CLI) to fix broken packages. Here’s how to repair broken Ubuntu installation.
If a package installation fails in Linux Ubuntu, it can cause few problems. For example, the package manager freezes or become locked. It is a bit problem to use Ubuntu properly while the system packages are broken or corrupt. Luckily, there are few ways to resolve the issue.
One can fix broken packages via command line (Terminal) or Synaptic Package Manager. Let us see how:
Method 1. If a Ubuntu package installation fails (due to dependencies), run the following command
sudo apt-get clean
sudo apt-get install -f
sudo dpkg --configure -a
sudo apt-get update
Method 2. If you encounter an error with MergeList or a missing “Package: header” error (read below):
E: Encountered a section with no Package: header
E: Problem with MergeList…
E: The package lists or status file could not be parsed or opened.
Then remove the package lists and recreate them using the following command:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
Method 3. If you get an error message with lock on the apt cache (read below):
E: Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable)
Then run the following commands:
sudo fuser -cuk /var/lib/dpkg/lock
sudo rm -f /var/lib/dpkg/lock
sudo fuser -cuk /var/cache/apt/archives/lock
sudo rm -f /var/cache/apt/archives/lock
Broken Packages usually happens because of ‘Unmet dependencies for installed packages’. This can be fixed via ‘Synaptic Package Manager.’ I assume you have installed Synaptic Package Manager on Ubuntu. Now run the following steps:
- Open Synaptic Package Manager ad go to ‘Status’ (left side)
- Choose ‘Broken’
- Remove these broken packages
- Exit
I hope the above commands and processes will resolve the problem.