7
votes

I was trying to install mono using following commands,

  1. sudo apt-get install mono-*

unfortunately, I closed the terminal while it installing. again i started to reinstall but shown error like

Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)

I tried below commands for solution,

  1. sudo rm /var/lib/apt/lists/lock
  2. sudo rm /var/cache/apt/archives/lock

But now I am getting the error like

dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

how do I fix this one?

6
you fix it by doing what it says. run that command and it clears things out. then you can reinstall mono - Russell Uhl
@RussellUhl now showing like "dpkg: error: parsing file '/var/lib/dpkg/updates/0001' near line 0: newline in field name `#padding' " - MMMMS

6 Answers

27
votes

This error occurs when you stop any installation while it's in progress. Regardless of whether you are using the terminal or the Ubuntu app center, the error will still be generated.

You can solve this by removing the broken installation. To do so, enter the following commands in the terminal in the order they are written.

   cd /var/lib/dpkg/updates
   sudo rm *
   sudo apt-get update
3
votes

run the command sudo dpkg --configure -a

1
votes

After searching a lot I got a satisfactory result:

I found some places saying to run commands:

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

But none of those above worked.

The solution that worked to me:

sudo dpkg --configure --pending

I hope this helps

0
votes

next time please don't use

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

or anything like that. Decent way to do this is

sudo killall apt-get
0
votes

you can also try to update your ubuntu by command :

sudo apt-get update && sudo apt-get upgrade

Sometime the dpkg needs some update to fix this problem.

0
votes

1. Remove the lock:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

2. Move to the updates dir:

cd /var/lib/dpkg/updates

3. Remove the all files from updates dir

sudo rm *

4. Take a fresh update

sudo apt-get update