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.

933 views

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

Tell us what you think:

  1. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. How to search a directory and subdirectories for a given string of text in Linux with the grep command.
  3. Worth knowing in order to make a bootable USB memory stick with Windows on from Linux.
  4. This is why I decided to encrypt my new Flash Drive, and why I think you should too.
  5. About the problem with using sudo with graphical programs in Linux.

More in: Linux Tutorials