If a package installation fails in Ubuntu, it can cause a package manager to freeze or become locked. When you start Ubuntu Software Center, it asks you to press button to repair broken packages in your system, but it does not always work.
Here are a few tips show you how to fix broken packages in command line. To get started, open terminal from the Dash or by pressing Ctrl+Alt+T on keyboard:
1. If a package installation fails due to dependencies issue, run below command in terminal:
sudo apt-get -f install && sudo dpkg --configure -a
The command either solves the dependencies, or removes the package (if dependencies unavailable) automatically.
2. If a problem occurs with MergeList, appearing as a missing “Package: header” error:
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 one:
sudo rm /var/lib/apt/lists/* -vf sudo apt-get update
3. If a problem occurs with a lock on the apt cache, for example:
E: Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable)
Then delete the locks by running below commands one by one:
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
If you have some more tips to fix broken packages in Ubuntu Linux, please don’t hesitate to leave a comment here.