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 it has just been delivered#

When a VPS is delivered or reinstalled, it automatically updates itself so that you receive an up-to-date system upon delivery.

You need to wait about 15 minutes for the installation of updates to finish.

You started an operation using DPKG that did not complete as expected#

  1. Check which process is using DPKG: sudo lsof /var/lib/dpkg/lock
  2. Get the PID number and kill the process, for example the PID number is 2913: sudo kill -9 2913
  3. Run the previous command again that did not work