Share via:

Solving: Could Not Get Lock, Apt-get Update Error

When updating Ubuntu you may sometimes run into a error, unable to lock directory. This is how to solve it.


Edited: 2017-05-12 12:02

Screenshot of the error: could not get lock.

Sometimes when trying to run update in Ubuntu, you might encounter an error like the below:

Reading package lists... Done

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)

E: Unable to lock directory /var/lib/apt/lists/

To fix this problem, you can try to remove all the files in the /var/lib/apt/lists/ directory:

sudo rm /var/lib/apt/lists/* -vf 

The v argument makes the rm command print the files it deletes, while f will delete them forcefully.

After deleting the files, simply run apt-get update as you normally would:

sudo apt-get update
sudo apt-get dist-upgrade