How To Fix “E: Could not get lock /var/lib/dpkg/lock” Error On Ubuntu

How To Fix “E: Could not get lock /var/lib/dpkg/lock” Error On Ubuntu

All

Linux Articles / All 53 Views comments

I've a Ubuntu 18.04 LTS digital machine which I exploit for testing functions. Every time I begin this VM and check out replace or set up any software utilizing APT package deal supervisor, I get the next error:

E: Couldn't get lock /var/lib/dpkg/lock-frontend - open (11: Useful resource briefly unavailable)
E: Unable to accumulate the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is one other course of utilizing it?

Or, one thing comparable errors like under:

E: Couldn't get lock /var/lib/dpkg/lock - open (11 Useful resource briefly unavailable)
E: Unable to lock the administration listing (/var/lib/dpkg/) is one other course of utilizing it?
E: Couldn't get lock /var/lib/apt/lists/lock – open (11: Useful resource briefly unavailable)
E: Unable to lock listing /var/lib/apt/lists/

It occurs each single time. I needed to look forward to a couple of minutes to carry out a apt operation.

I do know some course of has locked the apt database whereas putting in or eradicating  software program or updating the system within the background. I ran the “prime” command to research the record of operating processes. After wanting into the output of prime command, I got here to know that

Repair “E: Couldn't get lock /var/lib/dpkg/lock” Error On Ubuntu

Should you ever encountered with this drawback, await a couple of minutes till the presently putting in or updating or uninstalling activity to finish.

But when the method is caught for some cause and it locked the apt database for a number of minutes, you haven't any selection however take away the lock. In that case, comply with the under process to repair it.

First allow us to discover out which course of

$ sudo lsof /var/lib/dpkg/lock

If the lock file is totally different, for instance /var/lib/dpkg/lock-frontend, you will discover PID of the method that owns this lock file with command:

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

If the lock file is “/var/lib/apt/lists/lock”, run:

$ sudo lsof /var/lib/apt/lists/lock

Pattern output:

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
unattende 1548 root 6uW REG eight,2 zero 1181062 /var/lib/dpkg/lock

Could not get lock ubuntu

As you possibly can see within the above output, the PID of the method that holds the lock file is 1548.

Simply kill it to launch the lock utilizing command:

$ sudo kill -9 1548

Now you can safely take away the lock with instructions:

$ sudo rm /var/lib/dpkg/lock

Or,

$ sudo rm /var/lib/dpkg/lock-frontend

Or,

$ sudo rm /var/lib/apt/lists/lock

Additionally chances are you'll have to delete the lock file within the cache listing:

$ sudo rm /var/cache/apt/archives/lock

After eradicating the lock, run:

$ sudo dpkg --configure -a

This could repair the issue.

This technique will work simply advantageous 99% of time. However please be aware that if the replace course of is operating and also you killed the method in the midst of package deal set up, you may find yourself with damaged system. In such instances, don’t panic, simply comply with the under information to repair it.

Good luck!

Thanks for stopping by!

Assist us that will help you:

Have a Good day!!

Comments