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


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?


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


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »