16

I'm new to Ubuntu, it looks like it is better than Windows. Last day I tried to install Kget (the download manager) but during the process my computer suddenly stopped working. So I had to switch it off. After I logged into Ubuntu again I can't install any program. The Ubuntu Software Center says:

Items cannot be installed or removed until package catalog is repaired.
Do you want to repair it now?

After I clicked repair it says (after few seconds):

Package operation fails - The installation or removal of a software package failed

I've tried several times, but the same problem occurred. Can anyone tell me a solution for this problem?

0

3 Answers 3

24

To fix broken packages in Ubuntu, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command below.

sudo dpkg --configure -a
sudo apt-get install -f

If the problem still exist, then edit dpkg status file

gksudo gedit /var/lib/dpkg/status   

Find the package in question, and remove everything that has anything to do with it >and save the file.1

1Source:Ubuntu fix

2
  • 5
    Is editing the dpkg status file a pretty safe thing? Like, will I be running a large risk of screwing up my whole system?
    – user92942
    Dec 6, 2012 at 1:58
  • 2
    If you delete the package in question, should be OK.
    – Mitch
    Dec 6, 2012 at 11:38
16

Open a terminal and try this command

sudo apt-get install -f

It will fix all broken packages. after this you can install any s/w you want.

0
1

When upgrading from 13.10 to 14.04.1, I had a problem with broken packages, and when trying all the common things like apt-get -f install, I got an error, something like E: Sub-process /usr/bin/dpkg returned an error code (1).

Instead of reinstalling and spending hours setting things up, I got my hands dirty, and eventually fixed. Here's how:

  1. Synaptic uses apt-get underhood. Go use that apt-get at console. Figure out what commands are used by Synaptic, or which to use.

  2. apt-get uses dpkg internally. If it tells dpkg ended with an error, try to do the operation with dpkg directly, you'll see the actual error.

  3. dpkg stores it's metadata in /var/lib/dpkg/info/. In my case, it had problems with samba-libs, installing (corrupted archive) or removing (metadata missing -> saying it's not installed). So I deleted the metadata. Then ran dpkg --clear-avail. Then downloaded the library, put to the place instead of the corrupted file. Then apt-get update. Then dpkg --install <path-to-lib>. And then it started working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .