0

I get the following error:

 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?

every time I try to install new software and then I tried to kill the process. So I typed in the command 'ps -A | grep apt-get' and get no response from it.

How do I get rid of this lock?

Fabby
  • 35,017

2 Answers2

2

apt-get isn't the only front-end application thing that uses /var/lib/dpkg/lock.

Things like Update Manager and the Software Centre, Synaptic and aptitude all have their own ways of interfacing with the Apt and dpkg databases.

To find out what has it open, you can use fuser:

sudo fuser -u /var/lib/dpkg/lock

Then, if that's safe to kill (I'd advise people always check before using the -k flag), you can kill it and delete the lockfile.

Oli
  • 299,380
0

Using lsof <file> seems to work too.

For example, if I have synaptic running (live):

$ sudo lsof /var/lib/dpkg/lock

lsof: WARNING: can't stat() tmpfs file system /cow
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/999/gvfs
      Output information may be incomplete.
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF  NODE NAME
synaptic 20942 root   10uW  REG   0,18        0 39610 /var/lib/dpkg/lock

Then I know that synaptic with PID 20942 is what's opened the lock file, blocking other package management programs.

Xen2050
  • 8,943