Want to install monitoring agent but,I am getting Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

I am trying to install monitoring agent by running the command

curl -sSL | sh

But I am getting the response

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

I totally have no idea what this is,has anyone come across such issue or knows how to fix this?

Thank you.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

If you are doing this very early in the droplet creation process, eg. from a cloud-init script then the reason might be the fact that DigitalOcean’s local agent is also doing an apt-get update right after the droplet comes alive.

root       817  0.0  0.2   9576  2644 ?        S    07:56   0:00  \_ /bin/bash /var/lib/cloud/instance/sem/do_agent
root       842  2.0  0.6  35572  6728 ?        S    07:56   0:00      \_ apt-get -qq update
_apt       848  0.0  0.4  36224  5032 ?        S    07:56   0:00          \_ /usr/lib/apt/methods/http
_apt       849 14.0  0.4  36224  5044 ?        R    07:56   0:00          \_ /usr/lib/apt/methods/http
_apt       857  0.0  0.4  31856  4688 ?        S    07:56   0:00          \_ /usr/lib/apt/methods/gpgv
_apt       924  0.0  0.8  40104  8824 ?        R    07:56   0:00          \_ /usr/lib/apt/methods/store

The solution might be to wait a bit before doing the update or try again a few times until it succeeds.

This error indicates that another process is using the package system (apt). Since this controls the installation and update of software on your platform it’s limited to a single process at a time to prevent it being corrupted.

You can use ps afx|grep dpkg to check if there is still a process running at the same time. sudo killall dpkg will stop all running dpkg processes.

sudo rm /var/lib/dpkg/lock can be used to manually remove the lock if there isn’t any other process using it. This can happen if another process crashed earlier without releasing the lock.

As @Cronus89 said, you will have to either run these and your other commands as the “root” user or use sudo in front of your command.

You either have to run that as root, or prefix the command with sudo