How To Solve Unable to lock the administration directory (/var/lib/dpkg/) in Ubuntu

You got Unable to lock the administration directory error message when you try to run apt-get update command in Ubuntu? If you are getting below error message,

  • E: Could not get lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)
  • E: Unable to lock directory /var/lib/apt/lists/
  • 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?

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

    1. Search for processes

    ps -A | grep apt-get

    2. See if there is any process running as apt-get then kill that process

    sudo kill -9

     

    Unable to lock the administration directorySee above screenshot, when I run ps -A | grep apt-get , I got the id 10477. So I killed that process using ‘sudo kil -9 10477’.

    If you are sure that you have no instances of dpkg or apt running and you still get the message, you can just delete the lock file. A lock file is just a file with zero size that indicates locking of a resource. So to delete it tyep:
    sudo su
    sudo rm /var/lib/apt/lists/lock
    apt-get update

As of Ubuntu 16.04 release, apt-get was replaced with apt. The running process can be located with:
ps -A | grep apt

About Shino

Shino, the author of this blog is a 28 year old master graduate in Computer Science, a professional programmer and web developer. TechMagics.com is his humble venture to share whatever he knows and learns about programming,technology and web world.

Leave a Reply

Your email address will not be published. Required fields are marked *