I can't install packages on my VPS with Debian or Ubuntu
Problem encountered
When trying to update or install a package on Debian or Ubuntu the following error appears:
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?
Cause
This message appears when another instance of DPKG is running on your server.
Solution
You have just reinstalled your VPS or your VPS has just been delivered
When a VPS is delivered and reinstalled, it is automatically updated so that you can benefit from an up-to-date system at the time of delivery.
You must wait about 15 minutes for the installation of updates to finish.
You started an operation using DPKG that did not end as expected
Check which process uses DPKG :
sudo lsof /var/lib/dpkg/lock
Retrieve the PID number and kill the process, e.g. the PID number is 2913 :
sudo kill -9 2913
Restart the previous command that did not work
Updated on: 17/10/2022
Thank you!