0

I can't install some applications using apt-get.

It shows the following error. How to solve it?

$ sudo apt-get install apache2
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?
Zanna
  • 70,465

1 Answers1

2

This may break things if used carelessly. Try the answers on this question first: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

Did you have a problem while you were installing something previously? Your computer may've crashed while apt, apt-get or aptitude was doing some updates and so it left the lock file in the disk.

Try this:

sudo mv /var/lib/dpkg/lock /var/lib/dpkg/lock_backup

Then try to install apache again:

sudo apt-get install apache2

If everything works fine, just delete the backup file:

sudo rm -vf /var/lib/dpkg/lock_backup
wjandrea
  • 14,236
  • 4
  • 48
  • 98
  • Note that the contents of the file itself (/var/lib/dpkg/lock) are not important. It's its presence at that path that prevents bad things from happening. So there's no reason to make a backup. – wjandrea Mar 23 '18 at 17:03