5

I tried to install jdk/jre:

ben@ubuntu:~$ sudo apt-get install openjdk-7-jre-headless

However, I got this message:

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?

I cannot get git to install either, so I don't think it is a problem with the specific package I selected. What that error means, and how to deal with it?

  • Have you tried just rebooting? An error like that usually indicates that another package manager has locked the whole system. If you reboot, it should not persist. – Splinter of Chaos Jun 26 '12 at 22:18
  • 4
    @Ben7005 I'd hold off on the rebooting and wait for your downloads to finish – Levon Jun 26 '12 at 22:25
  • 3 years ago there was also this answer on askubuntu. – user44370 Nov 29 '13 at 5:53
9

Do you have the GUI package manager/or update manager programs running? If so there's a conflict, simply close those programs down and your command line should work.

  • I am downloading some software from the software center... I'll finish that and see if it works. – diracdeltafunk Jun 26 '12 at 22:22
  • 2
    @Ben7005 That's most likely it .. in fact trying to use both of those GUI programs at the same time will result in the same error message, so I'd not be surprised you'd get this with the command line while something else is going on. – Levon Jun 26 '12 at 22:25
  • 1
    That's definitely it. Only one of aptitude, apt-get, dpkg and the software centre can install at the same time. They use a lock on /var/lib/dpkg/lock to ensure that, hence the error message. – Alexios Jun 26 '12 at 23:20
  • 3
    Either that or one of the above frontends was /very/ rudely interrupted mid-install and its dpkg backend was still hanging on to the lock. Can sometimes happen running aptitude remotely and losing connection while dpkg was waiting for user input (eg, to tell it what to do with a modified config file) – Shadur Jun 27 '12 at 7:55
  • 1
    check if the lockfile exists, and if there is no dpkg/apt process running, delete it. – Arcadien Jun 27 '12 at 9:03
2

This should be used as last resource. If you use this carelessly you can end with a broken system. Please evaluate other answers first before trying this. You can delete the lock file with the following command:

sudo rm /var/lib/dpkg/lock

After that, try installing again.

  • It works on all linus distributions. Try removing it and install. – Ruban Savvy Nov 29 '13 at 4:11
  • 4
    It works on all distributions that use apt, not all Linuxes. It is also a pretty bad idea, as you point out, the OP should first look for running apt processes and kill them. – terdon Nov 29 '13 at 4:18
  • Yup @terdon I mentioned in first line that it should be done when no other solutions helps. – Ruban Savvy Nov 29 '13 at 4:20
0

This is what worked for me:

1) Open a terminal

2) sudo dpkg --configure -a

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.