[Error] Linux: Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)

Recently I was trying to install an application using the apt command on Ubuntu when I encountered the following error: 

  • 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?

In fact, there is a similar error you may see:

  • E: Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)
  • E: Unable to lock directory /var/lib/apt/lists/
  • 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?
These errors are very similar to another common Ubuntu error, Unable to lock directory /var/cache/apt/archives/, and the interesting thing is that the fixes are similar as well.

Fixing “Unable to lock the administration directory (/var/lib/dpkg/)” error

You see this error because some other program is trying to update Ubuntu. When a command or application is updating the system or installing a new software, it locks the dpkg file (Debian package manager). 

This locking is done so that two processes don’t change the content at the same time as it may lead to unwarranted situation and a possible broken system. 

Let’s see what steps can you take to fix this issue of ‘unable to lock administration directory’.

You can now safely remove the lock files using the commands below:  

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

After that, reconfigure the packages:

sudo dpkg --configure -a

Now if you run the sudo apt update command, everything should be fine.

Troubleshooting 1: “Unable to acquire the dpkg frontend lock”
 If you see an error like this:

  • E: Could not get lock /var/lib/dpkg/lock-frontend – open (11: Resource temporarily unavailable) 
  • E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
If the COMMAND is something else, you may kill the process and then remove the lock file. You can see the process id under the PID column. Use this PID to kill the process. After that, remove the lock file and run the update command to see if it’s been fixed.
sudo kill -9 PID
sudo rm /var/lib/dpkg/lock-frontend
sudo apt update

Troubleshooting 2: “dpkg: error: dpkg frontend is locked by another process” 

If you see the error “dpkg frontend is locked by another process” while running the steps in method 2, you need to one additional step. 

First, find out the id of the process that is holding the lock file.

sudo lsof /var/lib/dpkg/lock-frontend

The above command will give you the details of the processes using the lock files. Use the process ID to kill this program:

sudo kill -9 PID

Now you can remove the lock and reconfigure dpkg:

sudo rm /var/lib/dpkg/lock-frontend
sudo dpkg --configure -a
Did it work for you? Which method fixed it for you? Let us know in the comment….
– itsfoss

2020 || All rights reserved

Design and Developed by