"dpkg was interrupted error" when installing any application [duplicate]

I have ubuntu 11.10 and when I run any package management command in terminal I get this message

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a'
to correct the problem. 

What is the problem and how can I solve it?


The error message usually points to having interrupted a download in the past.

This should be resolved by the following:

sudo dpkg --configure -a
sudo apt-get -f install
sudo apt-get update && sudo apt-get upgrade