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

April 11, 2018 873 views
Apache Ubuntu 16.04

I am trying to install monitoring agent by running the command

curl -sSL https://agent.digitalocean.com/install.sh | 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.

2 Answers

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

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.

  • I had the same error and followed the steps above. Now I get

    E: dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem.
    
    • This is expected when killing a dpkg/apt process in this way. You should run the command recommended by the message which will reset your dpkg configuration and then you should be all set.

Have another answer? Share your knowledge.