Categories
Tips & Tricks

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

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

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 some chores so that I ended up losing the connection as I always use SSH.

Most of the time 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 reconfigure the packages. Run in terminal:

sudo dpkg --configure -a
sudo apt update

Then the problem should have been fixed!

By Vannkorn

I am a WordPress lover. I make my living using WordPress.

Leave a Reply

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