Vannkorn

Full Stack WordPress Developer

Close

E: Could not get lock /var/lib/dpkg/lock-frontend – … [Fix]

It happens when the update/upgrade list process failed due to connection lost or interrupted.

Ads: Register now via this link to receive $100 credit from Vultr

Image from Quick Notepad Tutorial

I’m hosting a few websites for some friends and clients which most of them are running on Ubuntu.

Once or twice a month I always go read logs remove cache and pull the patch if any.

The most common commands to pull those security updates I run are:

$ apt-get update
$ apt-get upgrade
$ apt-get dist-upgrade.

Sometimes I was distracted by my son, or I was away doing some chores and I ended forgot what I have left off so that the SSH connection lost halfway there. However, most of the time was the connection interruption.

I got the 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?

The easy fix is to remove the lock files that the dist-upgrade command has produced.

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

Then just go reconfiguring the packages like this:

sudo dpkg --configure -a
sudo apt update

The problem should have been fixed!

Leave a Reply

Your email address will not be published. Required fields are marked *