How Can I get the Process information of the process which is holding apt-get lock?
Asked
Active
Viewed 346 times
3
-
1You are right. Future readers may refer that question. – Vraj Pandya Dec 16 '16 at 18:47
1 Answers
4
Usually it's a dpkg process, so sudo lsof | grep 'dpkg/lock'
The output will be something like this:
apt-get 23126 root 4uW REG 8,18 0 3277485 /var/lib/dpkg/lock
And in my case, the apt-get process is holding the lock. pid 23126.
If nothing comes back as holding it open, then someone may have interrupted a package download or install and it wasn't able to clean up the lock.
If you want info on that process you could ps -f -p 23126
Or, putting it all together, ps -f -p $(sudo lsof | grep 'dpkg/lock' | awk '{print $1}')
Or use pstree and show the parents:
pstree -s $(sudo lsof | grep 'dpkg/lock' | awk '{print $1}')

Stephen
- 1,797
-
Will it always be dpkg process? Even if installation is done using software centre? – Vraj Pandya Dec 16 '16 at 01:57
-
1Pretty sure the software center uses dpkg in the background. You could use pstree to see the parents/children of the process in qustion. Updated answer. And it will always be that lock, if that's what you mean... – Stephen Dec 16 '16 at 01:58