0

Sometimes when I try to install something using sudo apt-get install it shows results looks like ---

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?

Now, I want to know the process(name , id) which is using it. If the process is no more needed I can kill it.

How can I know the process id?

alhelal
  • 2,621

1 Answers1

0

You can use "fuser" to get the pid of the pocess to kill:

sudo fuser /var/lib/dpkg/lock

you can use switch "-k" with fuser to kill the processes hanging on /var/lib/dpkg/lock

0x0C4
  • 713
  • 3
    It might not be the best idea to just kill the process. If dpkg is running, it is most likely busy manipulating the package database or installing/updating/removing some packages. Interrupting this might get you into trouble. Better just check what process is owning the lock and then wait a few minutes and check again, giving it a chance to exit normally. – Byte Commander May 06 '17 at 15:13
  • you right, Byte Commander. but this was not the question. – 0x0C4 May 06 '17 at 16:35
  • 1
    Yes, but an additional warning is always a good idea. Especially as not only the OP will read your answer but everybody who comes by and finds this question. – Byte Commander May 06 '17 at 16:45