I was browsing some questions here to find a solution to locating and removing broken packages. Being a relative novice I installed some PPAs designed for 11.10 on my 12.04 LTS machine. In terminal it suggested I try apt-get -f install which brought me to this question A big lesson learned for me, if anyone can help
Install the Synaptic Package Manager, either through the Software Center or by running this command in the Terminal:
sudo apt-get install synaptic
Open it by typing
synapticin the Unity dash and then hitting Enter.
Then follow this procedure:
- Select the "Status" category. This shows packages organized by status.
- Select "Broken dependencies" category from upper left pane.
- Select the broken packages. If the packages are more than one, select them all by pressing Ctrl+A.
- Then right-click on a selected package, and select the option "Mark for Complete Removal" in the menu.
That's it. The broken packages are gone.
Synaptic Package Manager (available in the Software Center) is a graphical tool for managing packages, and among many features it allows you to filter packages by their state. In few clicks, by selecting the desired category on the left panel, you will be presented with the list of packages that require fixing.
No downloads, no GUI needed:
You can list broken packages :
dpkg -l | grep ^..r
r state (on the third field) means: reinst-required (package broken, reinstallation required)
To list and remove these packages:
dpkg -l | grep ^..r | while read -r | tr -s ' ' | cut -d' ' -f2 | while read -r name; do sudo apt-get remove "$name"; done
(Answer copied from this thread.)
To clean up the packages you've installed from ppa, you should use
ppa-purge, assumed the ppa is ppa:xorg-edger/ppa
sudo apt-get install ppa-purge
sudo apt-get update
sudo ppa-purge ppa:xorg-edger/ppa
- it will prompt you a list of packages to remove and/or downgrade, if nothing look suspicious, answer Y and wait
- if you are lucky, it should finish with out error, else you'll need to do a
sudo apt-get install -f
If after step 5 you still have errors, come back and update your question.
I have made a script for fixing broken packages. This searches for the broken packages in the /var/log/dist-upgrade/apt.log and then finds the package names then applies the specified command on them.
Take care about using this script, because sometimes some broken packages are system related and might make a new problem. so use install or upgrade command instead of remove command.
Download the script using the below command:
Then run it:
Also you can set the action you want to apply to broken packages like this:
The default action is remove.