10

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?

  • Did you use sudo? – Arronical Feb 1 '19 at 9:43
  • 1
    Of course, I have used sudo :) – N0rbert Feb 1 '19 at 9:46
  • 6
    It's probably unattended-upgrade. If you auto-install any updates, it will do it. – mikewhatever Feb 1 '19 at 9:51
  • Perhaps try pgrepping for apt or unattended-upgrade, or use fuser on the lock file? – Arronical Feb 1 '19 at 9:54
  • Try running this command to find the process ps aux | grep -i apt – Aaron Obeng Feb 1 '19 at 10:01
9

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.

| improve this answer | |
  • 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 1 '19 at 10:18
  • 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 9:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.