How to Solve “Sub-process /usr/bin/dpkg returned an error code (1)” In Ubuntu

It’s not uncommon to run into an issue of broken packages in Ubuntu and other Debian-based distributions. Sometimes, when you upgrade the system or install a software package, you may encounter the ‘Sub-process /usr/bin/dpkg returned an error code’ error.

For example, a while back, I tried to upgrade Ubuntu 18.04 and I bumped into the dpkg error as shown below.

Errors were encountered while processing:
google-chrome-stable
E: Sub-process /usr/bin/dpkg returned an error code (1)

This indicates that the google-chrome-stable package is either broken or corrupt. There are a few workarounds to this problem, so don’t throw in the towel yet or discard your system.

Solution 1: Reconfiguring the dpkg Package

One of the triggers of this error is a corrupted dpkg database. This can be caused by the sudden interruption of the installation of a software package. Reconfiguring the database is one way to resolve this issue.

To do this, simply execute the command:

$ sudo dpkg --configure -a

This reconfigures the unpacked packages that were not installed during the installation process.

Solution 2: Force Install the Troublesome Package

Sometimes, errors can occur during the installation of software packages. When such happens, you can force install the package using the -f option as shown.

$ sudo apt install -f
OR
$ sudo apt install --fix-broken

The -f option & --fix-broken can be interchangeably used to fix broken dependencies resulting from an interrupted package or cached package download.

Solution 3: Purge the Bad or Corrupted Software Package

If the first two solutions did not fix the problem, you can remove or purge the problematic software package as shown.

$ sudo apt remove --purge package_name

For example, in my case, purging the Google chrome package fixed the issue.

$ sudo apt remove --purge google-chrome-stable

Then invoke the commands below to remove all the old, unused, and unnecessary packages which also frees up space on your hard drive.

$ sudo apt clean
$ sudo apt autoremove

Solution 4: Remove all the Files Associated with the Package

Lastly, you can manually remove all the associated with the troublesome package. First, you need to find these files which are located in the /var/lib/dpkg/info directory as shown.

$ sudo ls -l /var/lib/dpkg/info | grep -i package_name

After listing the files, you can move them to the /tmp directory as shown

$ sudo mv /var/lib/dpkg/info/package-name.* /tmp

Alternatively, you can use the rm command to manually remove the files.

$ sudo rm -r /var/lib/dpkg/info/package-name.*

Finally, update the package lists as shown:

$ sudo apt update

You can thereafter give it another shot in reinstalling the software package.

Conclusion

This type of dpkg error points to an issue with the package installer usually caused by the interruption of an installation process or a corrupt dpkg database.

Any of the above-mentioned solutions should fix this error. If you have come this far, then it’s our hope that the issue has been successfully resolved and that you were able to reinstall your software package.

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

20 thoughts on “How to Solve “Sub-process /usr/bin/dpkg returned an error code (1)” In Ubuntu”

  1. Thanks a ton!

    I could not clean a package entry for which I had deleted the folders and hence it was not being deleted or reinstalled. I couldn’t upgrade to the latest OS versions as well. Tried many solutions from many sources. But today I got your 4th solution and it worked and it also showed me the real cause of the issue.

    Thanks once again for the detailed post!

    Reply
  2. I have tried several times to install koha in ubuntu 20.04 but keeps giving this error

    Processing triggers for man-db (2.9.1-1) …
    Errors were encountered while processing:
    koha-common
    koha
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    Can any one help.

    Reply
  3. Hi everyone. gentlemen professionals help, please.

    I have tried a lot of what is written on the Internet, but it keeps getting an error.

    Generating grub configuration file ...
    Found linux image: /boot/vmlinuz-5.15.0-50-generic
    Found initrd image: /boot/initrd.img-5.15.0-50-generic
    Found linux image: /boot/vmlinuz-5.15.0-48-generic
    Found initrd image: /boot/initrd.img-5.15.0-48-generic
    Found linux image: /boot/vmlinuz-5.15.0-46-generic
    Found initrd image: /boot/initrd.img-5.15.0-46-generic
    Found linux image: /boot/vmlinuz-5.15.0-43-generic
    Found initrd image: /boot/initrd.img-5.15.0-43-generic
    /etc/grub.d/bin/grubcfg_proxy: error while loading shared libraries: libcrypto.so.1.1: cannot open shared object file: 
    No such file or directory
    run-parts: /etc/kernel/postrm.d/zz-update-grub exited with return code 127
    dpkg: Fehler beim Bearbeiten des Paketes linux-image-unsigned-5.15.0-47-generic (--remove):
    »installiertes linux-image-unsigned-5.15.0-47-generic-Skript des Paketes post-removal«-Unterprozess gab den Fehlerwert 1 zurück
    dpkg: Zu viele Fehler, Abbruch
    Fehler traten auf beim Bearbeiten von:
    linux-image-unsigned-5.15.0-47-generic
    Bearbeitung wurde angehalten, da zu viele Fehler auftraten.
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    nix@nix:~$
    
    Reply
      • Thank you, Tell me how to install it, and where to get it. I don’t understand programs very well.

        Even installing any package or deleting a package also shows an error. that the package Errors occurred while editing:

        linux-modules-5.15.0-47-generic

        Can you tell me how to do it? Thanks.

        Reply
        • Yup, I ran into this same exact situation. Going back and looking for missing libraries I was able to find their package names and do an apt-get install on each of them. So, after googling for hours, I finally came to this and got it finally fixed. Yay!

          Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.