Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable) error on Debian (or Ubuntu)

JeevesBond's picture

He has: 3,954 posts

Joined: Jun 2002

Just fixed an annoying problem on our Debian server and thought I'd share how it was done.

This problem occurs when you're in the middle of doing an aptitude upgrade or apt-get upgrade and you are no longer able to control the package manager. In my case, I lost the SSH connection to the server, just when it was asking me a question. So Aptitude just sat there waiting for me to reply.

Trying to restart the upgrade returns this error:

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

The first step to fixing this is to kill Aptitude (or apt-get), enter this at the terminal (hint: copy and paste is easiest):

killall aptitude && killall apt-get

Unfortunately, for me, this returned the same error message as before. I finally worked out that dpkg and frontend have to be killed off as well, enter this at the terminal:

killall dpkg && killall frontend

Which worked. However, trying to start the upgrade over again didn't, it returned this error:

E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
E: Couldn't rebuild package cache

So, to finally fix the problem, enter this at the terminal:

dpkg --configure -a

For me this started the upgrade from where it had left-off. If you find the same problem, but this doesn't fix it, share it here and hopefully we can help. Smiling

Note: this should work just as well under Ubuntu, just add sudo in front of all the commands.

a Padded Cell our articles site!

They have: 1 posts

Joined: Apr 2011

Hey friends,
just type
sudo bash (or) sudo -s
This makes you the root user and obtain administrator previlages. type “whoami” and check that you will be the root user…now all apt commands work..

They have: 1 posts

Joined: May 2011

thank you very very much. this is very helpful for me. thank you. good luck!

They have: 1 posts

Joined: Sep 2011

I always just remove the lock file

rm /var/lib/dpkg/lock

They have: 8 posts

Joined: Sep 2011

thank you very very much. this is very helpful for me. thank you. good luck!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.