E: Could not get lock /var/lib/dpkg/lock Error fix for forever in Ubuntu 16.04/14.04.6/18.04 etc

Опубликовано: 19 Февраль 2025
на канале: innomaths
9,984
92

###################################################
commands:
method 1:

ps aux | grep -i apt

sudo killall apt apt-get

method 2: (proceed along with video)

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

for each process, use
sudo kill -9 process_id
to kill the process.

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

sudo dpkg --configure -a

(in case of error)
sudo lsof /var/lib/dpkg/lock-frontend

sudo kill -9 PID
sudo rm /var/lib/dpkg/lock-frontend
sudo apt update

sudo dpkg --configure -a

###################################################
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.

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’.

Subscribe my channel to show support. Thank you for your kind actions.

#Ubuntu issues #errors