How to fix broken packages using the Command Line

Alexio
  13 years ago
  17

Using aptitude for package management instead of apt-get, please note that it is bad practice to use aptitude and apt-get interchangeably, as they record separately the changes made by a user.

 

Open the Terminal from the Mint Menu and start with the commands:

sudo aptitude update && sudo aptitude install gtkorphan

The && is used to run the second command if the first command runs successfully.

 

Continue by running:

sudo aptitude update && sudo aptitude upgrade

This is used to double-check that you have all the updates.

 

To clear out the broken packages use the command:

sudo aptitude -f

It brings up a beautiful interface to search, navigate, install, update and otherwise to manage packages.

Use the commands on the screen to install all the updates. You may use the mouse or CTRL + T to open the menu. Also, you could use the arrow keys and the Enter key to navigate.

You can also install the Aptitude Package Manager if you want to use something like Synaptic. Just type aptitude-gtk in the search field of the Mint Menu and click on Install package 'aptitude-gtk'. You can then find it under the Administration menu.

 

You may also use other commands to:

  • install software for your system, with needed dependencies as well:
sudo aptitude install
  • remove packages as well as orphaned dependencies:
sudo aptitude remove
  • remove packages and orphaned dependencies, as well as any configuration files left behind:   
sudo aptitude purge
  • search for packages in the local apt package lists:
sudo aptitude search package-name
  • show details about a package:
sudo aptitude show package-name
  • update the local packages lists:
sudo aptitude update
  • upgrade any installed packages that have been updated:
sudo aptitude upgrade
  • upgrade packages, even if it means uninstalling certain packages:
sudo aptitude dist-upgrade
  • delete only out-of-date packages, but keep current ones:
sudo aptitude autoclean
  • delete any downloaded files necessary for installing the software on your system:
sudo aptitude clean
  • fix a package at it’s current version, and don’t update it:
sudo aptitude hold

 

Recommended reading: Aptitude vs Apt-Get

Comments
Liqua 6 years ago

Life saver - thankyou.


LeeC 6 years ago

I was stuck in an apt-get "loop". Broken package couldn't be uninstalled.
"dpkg: error processing package ibm-java80-jre:amd64 (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
Errors were encountered while processing:
ibm-java80-jre:amd64"

Following the instructions in this article cleaned up the mess. Thank you very much!


Sam_Sung 7 years ago

there is no aptitude-gtk package to be found in synaptic


Sam_Sung 7 years ago

lifesaver!


Alexio 8 years ago

Using aptitude for package management instead of apt-get (via Synaptic), please note that it is bad practice to use aptitude and apt-get interchangeably, as warned at the very beginning of this tutorial.


Anaemic 8 years ago

It is not necessary to install a program to fix broken packages.
Open Synaptic Package Manager > click edit > click Fix Broken Packages


Alexio 8 years ago

Try the command:

aptitude why-not package

where package is the name of the package you want to install.

For details see http://unix.stackexchange.com/questions/121149/fix-held-broken-packages-on-debian


gorade 8 years ago

Very nice and instructive. only it didn't solve the problem. The irksome "solve the problem with broken packages" is still there. I am accused for "holding back broken packages". What do I do wrong?


Fokir 9 years ago

Nice and straight. We like this


Xzoma 9 years ago

Works great thanks


linux1492 10 years ago

This article rules!!! Thanks so much. Well done.


ssj_satish 11 years ago

Nice article. Solved the problem, I was hunting for 3 days.
Thanks a lot.


jaredchu 11 years ago

sudo aptitude -f

this command removed all my package, when i come back my computer return black screen and nothing in there...


blueXrider 13 years ago

Good information.


remoulder 13 years ago

I didn't say your post was an idea, following your instructions is not a good idea. It may well have worked for you but you probably understand what you are doing. An inexperienced user doing this could cause themselves problems.


Alexio 13 years ago

This is a tutorial and not an idea :) It worked well for me and for others when Synaptic was not able to fix the broken packages. It is possible to install a nice front-end to aptitude called "aptitude-gtk".


remoulder 13 years ago

This is not a good idea, users should understand what is causing the broken packages, not just force a fix or they could end up removing needed software. Besides imo, it is easier to see what is going on using synaptic rather than aptitude.