*NIX Tricks

[ubuntu] Unlock /var/lib/dpkg/lock when you’re locked out

Posted in ubuntu by kousik on October 2, 2009

You must have seen this (that’s why you’re here after all!)


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?

This often happens if you try to install a package (say, <package-name>) while you are installing another. As an example, this may happen when you try to run
$ sudo aptitude install <package-name>
in the terminal while you have Synaptic package manager open (or vice versa) or in another terminal you are installing another package . The easiest solution is just to wait for the other installation(s) to finish  and close the package manager if you are done with it. However, if the package manager is crashed in the middle some stuck-up  processes may still be using the lock (/var/lib/dpkg/lock).

In that case, use fuser to find out the runaway process(es); and while you’re at it, you may use -k flag which will kill the process that is still using /var/lib/dpkg/lock. Then configure (--configure) all the packages (-a) which are yet unpacked and unconfigured, using dpkg:


$ sudo fuser -vki /var/lib/dpkg/lock; sudo dpkg --configure -a

In the first command (fuser), the -i flag asks for user confirmation, and -v is for verbose mode.

After that, proceed to the usual installation step of the package that you want to install.

20 Responses

Subscribe to comments with RSS.

  1. John Ferry said, on October 13, 2010 at 1:20 PM

    HEY THANKS A LOT! When I went to this site this is the only one that worked! AWESOME INSTRUCTIONS!

  2. Chris said, on December 17, 2010 at 5:38 AM

    cheers mate worked great! :D

  3. Adam said, on January 27, 2011 at 12:46 AM

    helped out a lot thx awesome instructions no joke!

  4. Jonathan said, on February 7, 2011 at 11:06 PM

    Thank you so much !!!!

  5. yuva said, on March 20, 2011 at 7:52 AM

    Great !! It helped a lot..

  6. karthick said, on April 29, 2011 at 1:40 AM

    Thanx a lot.. well explained

  7. zach said, on June 16, 2011 at 12:39 AM

    thanks so much ive tried at least 50 other sites this is the only one that worked thank you so much

  8. abel said, on July 9, 2011 at 8:22 AM

    yeah! i stop searching here thanks

  9. rahul said, on August 25, 2011 at 6:46 AM

    thank u!!!!!!!

  10. Elipeta Sotabento said, on December 6, 2011 at 3:59 AM

    i love it!! thank you so much

  11. sahil khanna said, on December 11, 2011 at 6:24 AM

    excellent thanks a lot i am new user of ubuntu and it helped so very much but why do we get this error if you can explain that it would be of great help as then in future we would be more aware of not making any fault. ;) but thanks a ton for this

  12. Henry said, on December 19, 2011 at 1:48 AM

    i dnt knw why mine is still the same.. it said error… dkpg is locked by another process

  13. yogesh said, on January 3, 2012 at 3:32 AM

    it’s not working………….
    is there another way to do it.
    even i can’t open synaptic manager also.

  14. Priya said, on January 14, 2012 at 9:27 PM

    I was not able to do that. I got the following error message:
    dpkg: error processing man-db (–configure)

    What should I do with that? It will be great if you could help me with that..

  15. Joe said, on March 7, 2012 at 3:27 PM

    I knew the second part, but I was manually hunting all over the place for lock files. Thank you!

  16. [...] liat link ini deh. Ane lagi males nulis. ini asal nyatet aja, kalo2 lupa.http://nixtricks.wordpress.com/2009/10/02/ubuntu-unlock-varlibdpkglock-when-youre-locked-out/ [...]

  17. [...] from: http://nixtricks.wordpress.com/2009/10/02/ubuntu-unlock-varlibdpkglock-when-youre-locked-out/ Like this:LikeBe the first to like this post. Posted in OS [...]

  18. Philip said, on April 15, 2012 at 10:57 AM

    Thank you very much! That worked =)
    /Phil

  19. Linmoy said, on May 25, 2012 at 9:06 AM

    thanx man…great work


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.