21

I have just booted my clean Ubuntu 18.04 LTS VM and tried to install some application with sudo apt install.

But got error message:

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?

What process created the /var/lib/dpkg/lock-frontend file in Ubuntu?
How to gently stop it and take manual control on APT?

N0rbert
  • 99,918

1 Answers1

25

As was recommended in comments - I have checked the owner of the file

$ sudo fuser -v /var/lib/dpkg/lock-frontend
                     USER        PID ACCESS COMMAND
/var/lib/dpkg/lock-frontend:
                     root       2112 F.... unattended-upgr

$ ps aux | grep 2112
root      2112 66.5  8.1 366108 113508 ?       Sl   13:03   0:28 /usr/bin/python3 /usr/bin/unattended-upgrade --download-only

$ dpkg -S /usr/bin/unattended-upgrade
unattended-upgrades: /usr/bin/unattended-upgrade

So this file was created by /usr/bin/unattended-upgrade from unattended-upgrades package. I can kill it with:

sudo kill -KILL 2112 

and take control with

sudo apt install -f
sudo dpkg --configure -a
sudo apt-purge unattended-upgrades

as I forgot to purge it on this VM.


Note: do not purge unattended upgrades on your system if unsure. It needs some time to finish (depends on internet connection speed and disk speed) and then you can use APT as usual.

N0rbert
  • 99,918
  • 2
    You might want to add that unattended-upgrades only needs a bit time and then the lock file will be gone without any interaction. – Videonauth Feb 01 '19 at 10:18
  • 2
    The question asks for gently stopping the process but the KILL signal does kill it immediately. You should use the default TERM signal instead, see man kill. – Melebius Jul 15 '19 at 09:45
  • 1
    Debian bullseye 11.0, no Internet connection, the unattended-upgrade process is interminable but by sudo kill -9 <pid>. Even if there is a local mirror configured in sources.list, it isn't smart enough to use it. I keep a local debian mirror for i386, and amd64 platforms, because it actually uses less bandwidth than using a remote mirror for many machines. It's also good if you want to get an install done without exposing it to the Internet before routine hardening is complete. – Brian Nov 07 '21 at 02:52