could not get lock /var/lib/dpkg/lock | resource temporarily unavailable
When executing apt-get
is the command getting an error like “could not get lock /var/lib/dpkg/lock” or a variant of this error are like these?
could not get lock /var/lib/dpkg/lock-frontend
could not get lock /var/lib/dpkg/lock – open
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?
could not get lock /var/lib/dpkg/lock – open (35 resource temporarily unavailable)
could not get lock /var/lib/dpkg/lock open
could not get lock /var/lib/dpkg/lock-frontend
could not open lock file /var/lib/dpkg/lock
Solutions available for “could not get lock /var/lib/dpkg/lock“
You will get this message if you forget to use sudo
Otherwise, this is a sign that something else is installing or removing software and has locked the apt database while it performs the actions. The programs that can do this are:
- The Software Center
- The Update Manager
- The apt link installer (I think this now goes through SC)
- The apt-get or aptitude command-line utilities.
- The Synaptic Package Manager
Solution 1 : Kill the dpkg process and remove lock files
- First, check if there is a dpkg process running,
ps afx|grep dpkg
- If that’s the case, kill it below command
sudo kill processnumber
if the above one not works, kill the process forcefully.sudo kill -9 processnumber
orsudo killall dpkg
- Remove the lock files
sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
Solution 2 : Reconfigure dpkg
- Remove your
/var/lib/dpkg/lock
file
sudo rm /var/lib/dpkg/lock - force package reconfiguration.
sudo dpkg –configure -a
Hope these solves your issue, please comment below if you’re still facing issue.