Which is the process using apt-get lock?

69,321

Solution 1

Try using sudo lsof /var/lib/dpkg/lock to see which process has locked the updater.

You can also use ps -ax | grep dpkg or ps -ax | grep apt however there is also the software centre and auto-updater which could be blocking the process at which point you can kill the offending processes using kill <process id number>.

Have a look here for some more things you can try if these don't work Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

Solution 2

Enter following line to find the process ID:

lsof /var/lib/dpkg/lock-frontend

Then run this command with the PID that it revealed:

kill -9 PID
Share:
69,321

Related videos on Youtube

userDepth
Author by

userDepth

Updated on September 18, 2022

Comments

  • userDepth
    userDepth almost 2 years

    I don't have any package installations running, yet I get the following error when I try to install a DEB package. I thought about rebooting the system but that could corrupt the database. And it has happened before.

    sudo dpkg -i slack-desktop-2.1.2-amd64.deb 
    dpkg: error: dpkg status database is locked by another process
    

    sudo apt-get update
    Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
    Hit:2 http://dl.google.com/linux/chrome/deb stable Release
    Hit:4 http://archive.ubuntu.com/ubuntu xenial InRelease
    Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB]
    Hit:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease
    Hit:7 http://archive.ubuntu.com/ubuntu xenial-security InRelease
    Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main Sources [188 kB]
    Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/universe Sources [94.2 kB]
    Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [387 kB]
    Get:11 http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [383 kB]
    Get:12 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [147 kB]
    Get:13 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [326 kB]
    Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [323 kB]
    Get:15 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [113 kB]
    Fetched 2,058 kB in 5s (360 kB/s)                                
    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?
    

    • steeldriver
      steeldriver almost 8 years
      Please edit your question to include the exact command you are using and the complete error message.
  • userDepth
    userDepth almost 8 years
    sudo lsof /var/lib/dpkg/lock Did the work