RSS

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

02 Oct

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.

About these ads
 
24 Comments

Posted by on October 2, 2009 in ubuntu

 

Tags: , , , , , , , , ,

24 responses to “[ubuntu] Unlock /var/lib/dpkg/lock when you’re locked out

  1. John Ferry

    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

    December 17, 2010 at 5:38 AM

    cheers mate worked great! :D

     
  3. Adam

    January 27, 2011 at 12:46 AM

    helped out a lot thx awesome instructions no joke!

     
  4. Jonathan

    February 7, 2011 at 11:06 PM

    Thank you so much !!!!

     
  5. yuva

    March 20, 2011 at 7:52 AM

    Great !! It helped a lot..

     
  6. karthick

    April 29, 2011 at 1:40 AM

    Thanx a lot.. well explained

     
  7. zach

    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

    July 9, 2011 at 8:22 AM

    yeah! i stop searching here thanks

     
  9. rahul

    August 25, 2011 at 6:46 AM

    thank u!!!!!!!

     
  10. Elipeta Sotabento

    December 6, 2011 at 3:59 AM

    i love it!! thank you so much

     
  11. sahil khanna

    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

    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

    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

    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

    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. Philip

    April 15, 2012 at 10:57 AM

    Thank you very much! That worked =)
    /Phil

     
  17. Linmoy

    May 25, 2012 at 9:06 AM

    thanx man…great work

     
  18. rikoy

    July 4, 2012 at 12:07 PM

    thanks you..

     
  19. nana

    July 8, 2012 at 11:55 AM

    thanx man….it worked

     
  20. hanes

    March 24, 2013 at 12:08 PM

    Thank You.
    now the update-manager is working again

     
  21. John MIHIGO

    October 25, 2013 at 1:24 PM

    this is really helpfull

     

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 )

Google+ photo

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

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 34 other followers

%d bloggers like this: