Q:

What process created the /var/lib/dpkg/lock-frontend file in Ubuntu?

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?

A:

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.

