[Solved] Error: sub-process usr/bin/dpkg returned an error code (1)

[Solved] Error Sub Process Usrbindpkg Returned An Error Code 1

This error: E: Sub-process /usr/bin/dpkg returned an error code (1) may come due to broken packages, corrupt software installer, or maybe due to some interruptions during installation. You may get this error while updating the system, installing or uninstalling a package. This error is common in Ubuntu and there are several ways to solve it. We will be discussing them below:

Solution 1: Reconfiguring the dpkg database

While installing a package, if it’s interrupted in between, the dpkg database may get corrupted and you will get this error. But it can be solved by reconfiguring the dpkg database. To reconfigure the database, execute the following command in a terminal window:

sudo dpkg --configure -a
dpkg-error-1

This command reconfigures the unpacked packages that have not been installed. If this method doesn’t work out, you can try the subsequent methods.

Solution 2: Force-install the package

This method is used to fix the broken dependencies that may occur due to interruption during downloading or installing. Execute the following command to force install or fix the broken packages.

sudo apt install -f

or

sudo apt install --fix-broken

Solution 3: Remove the corrupted packages

If both the methods didn’t work out, It’s better to remove the corrupted packages and re-install them. To remove the package, execute the following command:

sudo apt remove --purge package_name

Replace the package_name with the name of the package you want to remove.

sudo apt remove --purge brave-browser
dpkg-error-4

Here, I have removed the brave-browser package using the above command. Using purge command uninstalls the software package along with its configuration file.

Now, Execute the following commands to remove the unused and unnecessary packages:

sudo apt clean
sudo apt autoremove
dpkg-error-5

Solution 4: Overwriting the corrupted package

If any of the above methods don’t work, execute the following command to overwrite the existing package:

sudo dpkg -i --force-overwrite /var/cache/apt/archives/package_name

Replace the package_name with the actual package name you want to overwrite.

Conclusion

So, we discussed several methods to solve the error. This error is common and mostly due to interruption in the installation package. Try any of the above methods. I hope it works out for you.