Tips – Tricks Ubuntu

How to fix could not get lock error in ubuntu

If you try to get ubuntu update by apt-get update command and you get these errors could not get lock /var/lib/apt/lists/lock or Could not get lock /var/lib/dpkg/lock. I will show you how to fix this problem in this article. Could not get lock error happens when you try to run or execute an apt command but forget to use “sudo”, or something has locked the apt database after install or remove software. These Ubuntu programs may be make the problem

  • Apt command
  • Ubuntu Software Center
  • Update Manager

You will likely to see these errors

$ sudo apt-get update 
Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable) 
Unable to lock directory /var/lib/apt/lists/

or

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/)

You can fix that problem by simply remove all of the temporary list in /var/lib/apt/lists/ and lock file in the cache directory in /var/cache/apt/archives/lock

$ sudo rm /var/lib/apt/lists/*
$ sudo rm /var/lib/dpkg/lock
$ sudo rm /var/cache/apt/archives/lock

Now we should force package to reconfig

$ sudo dpkg --configure -a

Now you can try to update your Ubuntu system or run Synaptic without “could not get lock” error.

Post Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.