How can I fix E: Sub-process /usr/bin/dpkg returned an error code (2)?

Try first:

sudo rm /var/lib/dpkg/available 
sudo touch /var/lib/dpkg/available  
sudo sh -c 'for i in /var/lib/apt/lists/*_Packages; do dpkg --merge-avail "$i"; done'

Dangerous, if previous instruction does not solve the problem...

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

Last may cause huge traffic load.


I know this is an old post but I got the same error. I fixed the problem with this command:

sudo dpkg --configure -a

Tags:

Dpkg

Lubuntu