Ubuntu – dpkg: error: dpkg status database is locked by another process

dpkg

I just wondered if somebody could tell me what this means:

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
reidsr@ubuntu:~$ sudo dpkg --configure -a
dpkg: error: dpkg status database is locked by another process
reidsr@ubuntu:~$ 

How do I run sudo dpkg --configure -a manually?

Best Answer

First run:

lsof /var/lib/dpkg/lock

Then make sure that process isn't running:

ps cax | grep PID

If it is running:

kill PID
#wait
kill -9 PID

Make sure process is done:

ps cax | grep PID

Then remove the lock file:

sudo rm /var/lib/dpkg/lock

Let dpkg fix itself:

sudo dpkg --configure -a

You should be fine afterwards :)

Related Question