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

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

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
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 :)

  • 6
    One should never remove lockfiles manually. They're there for a reason. Please, only use this as a very last resort. First try to identify and close other applications using the package management. – gertvdijk May 6 '13 at 16:06
  • 6
    If there is a process actually using the lock file, it would probably be better to kill that process instead of just removing the lock file. You should be able to find the process with lsof /var/lib/dpkg/lock. – Abe Voelker May 27 '14 at 15:34
  • A strong +1 for Abe's comment. Never remove a lockfile without killing all processes that have open file descriptors to it. – Pooyan Khosravi Jan 20 '15 at 6:48
  • 1
    @Xen2050 IMO a new answer adds unnecessary clutter. If you think a bash script that does same thing automatically is usable I'll write it as another answer. – Pooyan Khosravi Jan 20 '15 at 8:13
  • 1
    As it stands now, this is definitely the best answer. Yes, it is very important to make sure no running process owns the lock. I'd already checked that, nothing was running, and I needed to know how to delete the old lock. This answer covers all the bases. – Lambart Apr 4 '15 at 19:00

You can not run several packages applications/commands/tools at the same time. Sometimes, it means that synaptic, apt-get or the package update tool are running in the backgroung. Just close other package tools, or wait for them to be finished. And dpkg will run.

One could also try:

sudo apt-get install -f

To fix any broken packages:

Fix; attempt to correct a system with broken dependencies in place. This option, when used with install/remove, can omit any packages to permit APT to deduce a likely solution. If packages are specified, these have to completely correct the problem. The option is sometimes necessary when running APT for the first time; APT itself does not allow broken package dependencies to exist on a system. It is possible that a system's dependency structure can be so corrupt as to require manual intervention (which usually means using dselect(1) or dpkg --remove to eliminate some of the offending packages). Use of this option together with -m may produce an error in some situations. Configuration Item: APT::Get::Fix-Broken.

Following should help:

sudo rm /var/lib/dpkg/lock

sudo dpkg --configure -a

This can happen if the upgrade process was interrupted (like you're connection was lost). You can try using screen as root (sudo su) to get back into the session.

screen -r

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.