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?

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

1 Answer 1

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.

3
  • 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, 2019 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, 2019 at 9: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 7, 2021 at 2:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .