apt | How to Fix E: Sub-process /usr/bin/dpkg returned an error code (1)

How to Fix E: Sub-process /usr/bin/dpkg returned an error code (1)

You might have got this error while installing or updating some packages in debian based Linux. Dpkg retured and error code(1) means the package is corrupted or either broken.

apt | How to Fix E: Sub-process /usr/bin/dpkg returned an error code (1)

Different type of methods

You may have tried to fix this with

sudo dpkg --configure -a

or

sudo apt install --fix-broken

or

sudo apt autoremove

etc and so on. A lot of times these method works but if it is still not solved then here’s how to solve.

Most effective method to solve this error

This method include removing all files related to the corrupted file. Don’t worry you can download them again and it won’t affect your existing files and applications.

First you need to see all the files that are causing this problem. For that just ls /var/lib/dpkg/info You might have got lot of files we just need corrupted file in our case it is bacula-console-qt so we’ll use grep to filter the files.

sudo ls -l /var/lib/dpkg/info | grep -i bacula-console-qt

we get list of all files

apt | How to Fix E: Sub-process /usr/bin/dpkg returned an error code (1)

We’ll move all those files into tmp folder. to choose all the files we’ll use regular expression * for common word

sudo mv  /var/lib/dpkg/info/bacula-console-qt.* /tmp

Finally update

sudo apt update

Error solved now try to install.

apt | How to Fix E: Sub-process /usr/bin/dpkg returned an error code (1)

No error this time.

Related Posts