Tuesday, November 6, 2018

Ubuntu:: Unable to lock the administration directory (/var/lib/dpkg/)

I encountered an error, when I tried to use apt-get command in Ubuntu Linux command line.


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?

This error may be caused by the "Update Manager" trying to automatically refresh the list of packages in background, usually right after login, thus locking the directory.

In this case just wait few seconds (or more, if last update was long ago) for it to complete or launch Update Manager to check the status.

And check if 'Update Manager' running. If the error appears even though 'Update Manager' is not running, then remove stale apt lock file manually from "/var/lib/dgkg/lock" and force package reconfiguration.

Remove the apt lock file in the /var/lib/dpkg/ directory:

sudo rm /var/lib/dpkg/lock

Force package(s) to reconfiguration:

sudo dpkg --configure -a

Alternatively, delete the lock files in the /var/lib/apt/lists/ and cache directory as below:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

Now apt update command will work without any issues.

No comments:

Post a Comment

Provide your thoughts !