I thought this was fixed
When I got my Ubuntu LAMP server working, I was overjoyed.

Now the LAMP server works but I'm running into serious problems trying to install a mail server on the same Ubuntu VM.

It's the same error, just with a different command:

sudo apt -y upgrade
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?

Sorry for any typos in the above code. I was too lazy to use the browser in my VM so I hand typed the code.

How do I fix this permanently? I tested and confirmed the LAMP server still works. I fixed it once but I don't wanna have to do that every time for the same error if I can avoid it.
Does normal command work?
Code [No Highlight]:

sudo apt-get upgrade

Grap the PID blocking
ps -e | grep -e apt -e adept | grep -v grep
Kill it.
What happens is, when something is using dpkg, it locks it so nothing else can use it at the same time. You don't want 2 different processes trying to write files to the same thing or you'll probably get corruption.

so either you have dpkg running already, or is stuck running in the background. In this case you'll want to end that process. Insider gave you to the code to find this scenario, then you just need to kill it using kill -9 PID (PID=Process ID). But make sure you want to do this. killing a process while it's writing over files could be damaging.

the other option is, the process didn't end cleanly. Maybe you used kill -9 above, or maybe the server restarted, and nothing told the system to remove the lock file. In which case you'll need to go find the lock file and delete it. it will be something like /var/lib/dpkg/lock.

How you fix it permanently means determining what caused it in the first place. Did your server crash while doing an install? probably can't fix it permanently unless you fix why the server crashed. Is the process stuck? Need to find out why the process got stuck to fix it permanently. this issue is a safety feature that you shouldn't want to fix permanently. You should want to fix whatever problem is causing it. And there may be any number of things that are causing it. And it might not be the same problem causing it every time.