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 resolving 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.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

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

  1. I did make all processes to deinstall, in my case, VirtualBox.

    But, to a total surprise, the program yet is in my Linux Mint system.

    I have a Linux Mint 20.2 Uma

    I tried to eliminate the software because I had the error “sub-process /usr/bin/dpkg returned an error code (1)“.

    I don’t know what happened.

    Reply
  2. Hello,

    I have Ubuntu release 21.04 (Hirsute Hippo) 64-bit with Kernel Linux 5.11.0-18-generic x86_64 and MATE 1.24.1.

    My Software Updater failed.

    I tried:

    <sudo apt autoremove && sudo apt clean && sudo apt update && sudo apt 
    

    and got

    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
    2 not fully installed or removed.
    After this operation, 0 B of additional disk space will be used.
    Setting up usrmerge (24ubuntu3) ...
    
    FATAL ERROR:
    Both /bin/usb_printerid and /usr/bin/usb_printerid exist.
    
    You can try correcting the errors reported and running again
    /usr/lib/usrmerge/convert-usrmerge until it will complete without errors.
    Do not install or update other Debian packages until the program
    has been run successfully.
    
    dpkg: error processing package usrmerge (--configure):
     installed usrmerge package post-installation script subprocess 
    returned error exit status 1
    Setting up postfix (3.5.6-1) ...
    
    Postfix (main.cf) configuration was not changed.  If you need to make changes,
     
    edit /etc/postfix/main.cf (and others) as needed.  To view Postfix 
    configuration values, see postconf(1).
    
    After modifying main.cf, be sure to run 'systemctl reload postfix'.
    
    Running newaliases
    newaliases: warning: valid_hostname: misplaced delimiter: igor-System-Product-
    Name..
    newaliases: fatal: file /etc/postfix/main.cf: parameter myhostname: bad parame
    ter value: igor-System-Product-Name..
    dpkg: error processing package postfix (--configure):
     installed postfix package post-installation script subprocess returned error 
    exit status 75
    Processing triggers for libc-bin (2.33-0ubuntu5) ...
    Errors were encountered while processing:
     usrmerge
     postfix
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    Please advise.
    Thank you.
    Igor

    Reply

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.