Home Linux troubleshooting Fix “Sub-process /usr/bin/dpkg returned an error code (1)” In Ubuntu

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

By sk
Published: Last Updated on 211.5K views

Today I tried to upgrade my Ubuntu 20.04 LTS desktop and I encountered with this error - "Sub-process /usr/bin/dpkg returned an error code (1)". It is one of the common issue in Ubuntu and other DEB-based systems.

This error usually happens due to a failed application installation, or if the dpkg package installer becomes corrupted or interrupted in mid-way while installing a package.

Here are the commands that I tried to upgrade my Ubuntu desktop:

$ sudo apt update
$ sudo apt upgrade

And... here is the error message:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  eog
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
21 not fully installed or removed.
Need to get 0 B/421 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 
(Reading database ... 230012 files and directories currently installed.)
Preparing to unpack .../eog_3.36.2-0ubuntu1_amd64.deb ...
Unpacking eog (3.36.2-0ubuntu1) over (3.36.1-1) ...
dpkg-deb (subprocess): decompressing archive member: lzma error: compressed data is corrupt
dpkg-deb: error: <decompress> subprocess returned error exit status 2
dpkg: error processing archive /var/cache/apt/archives/eog_3.36.2-0ubuntu1_amd64.deb (--unpack):
 cannot copy extracted data for './usr/lib/x86_64-linux-gnu/eog/libeog.so' to '/usr/lib/x86_64-linux-gnu/eog/libeog.so.dpkg-new': unexpected end of file or stream
Errors were encountered while processing:
 /var/cache/apt/archives/eog_3.36.2-0ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Sub-process usr bin dpkg returned an error code 1
Sub-process usr bin dpkg returned an error code 1

Fix "Sub-process /usr/bin/dpkg returned an error code (1)" In Ubuntu

If you encountered with an error like above, worry not! Here, I have given a few workarounds to solve "Sub-process /usr/bin/dpkg returned an error code (1)" issue in Ubuntu and its variants such as Linux Mint, Pop OS.

Solution 1 - Reconfigure dpkg database

If the package installation process is stopped or interrupted in mid-way, the dpkg database might be corrupted. Reconfiguring dpkg database may solve this issue.

To reconfigure dpkg database, simply run:

$ sudo dpkg --configure -a

This command will try to fix the corrupted dpkg database and then reconfigure all broken packages. This command usually fixes the dpkg returned an error code (1) problem. If it didn't solve the issue for any reason, follow the subsequent solutions.

Solution 2 - Force install the application

If the first method didn't work, run the following command to perform force install:

$ sudo apt-get install -f

Or,

$ sudo apt-get install --fix-broken

Here, -f (or --fix-broken) option will attempt to correct the Ubuntu system with broken dependencies.

If these two solutions didn't help and the issue still persists, try the next solution.

Solution 3 - Remove the problematic application .deb file from the local cache folder and reinstall it

As you see in the error message (the last two lines), the eog package is causing this error.

[...]
/var/cache/apt/archives/eog_3.36.2-0ubuntu1_amd64.deb 
E: Sub-process /usr/bin/dpkg returned an error code (1)

For those wondering, eog (short for Eye of GNOME) is the official and default image viewer for the GNOME desktop environment. So this package is problematic and doesn't let me to upgrade my Ubuntu.

When you install a package, it will be downloaded and saved in the cache folder /var/cache/apt/archives/.

To fix this error, remove the cached package using command:

$ sudo rm /var/cache/apt/archives/eog_3.36.2-0ubuntu1_amd64.deb

Replace eog_3.36.2-0ubuntu1_amd64.deb with your package.

Clean the package cache folder:

$ sudo apt-get clean
$ sudo apt-get autoremove

Update the source lists:

$ sudo apt-get update

Upgrade your system:

$ sudo apt-get upgrade

Finally, get the fresh package from official repositories and reinstall it like below:

$ sudo apt-get install eog

This solution worked for me.

Solution 4 - Remove the problematic application

This should be your last resort. If none of the above methods help, remove the problematic package from your system like below:

$ sudo apt-get remove --purge eog
$ sudo apt-get clean && sudo apt-get autoremove

This command will remove eog with all its configuration files from the system.

And also find and remove all files associated with the broken package.

To find all files related to a package, run:

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

Sample output:

-rw-r--r-- 1 root root 61926 Apr 24 13:42 eog.list
-rw-r--r-- 1 root root 5889 Mar 29 08:01 eog.md5sums

Remove them manually.

That's it. At this stage, any one of the these four solutions should have helped you to fix "Sub-process /usr/bin/dpkg returned an error code (1)" in Ubuntu and other DEB-based systems.

You May Also Like

12 comments

Chris McGimpsey-Jones June 30, 2020 - 5:26 pm

Thank you. I had this precise problem. Method #1 worked for me.

Reply
Antonio July 25, 2020 - 10:22 am

Hi.
trying to install telegram through the terminal I had this error:

dpkg: error: error de configuración: /etc/dpkg/dpkg.cfg.d/multiarch: 1: opción `foreign-architecture’ desconocida
E: Sub-process /usr/bin/dpkg returned an error code (2)

I would appreciate the help you can provide

Thank you for your attention

Reply
anonym September 27, 2020 - 8:16 am

A lot of thanks!!!!
I tried a lot of methods of a lot of webs and only deleting the package files from the dpkg list worked.

Reply
Alan October 10, 2020 - 2:43 am

Thank you! I had the same experience as ANONYM. I looked at numerous web pages and tried all their suggestions, without success. Your Method #4 finally worked for me (“Remove the problematic application”). I have made a small donation at https://ostechnix.com/donate/. This is my new go-to site for all things Open Source and Linux.

Reply
sk October 10, 2020 - 11:43 am

Thank you very much, Alan. I am very grateful.

Reply
Hygiea November 12, 2020 - 4:59 am

Whenever I tried a solution, the error it was meant to fix messed it up. I’m honestly clueless

Reply
Ryan Steven December 7, 2020 - 6:10 pm

When I executed sudo apt –fix-broken install, I didn’t see this line:

debconf: DbDriver “config”: /var/cache/debconf/config.dat is locked by another process: Resource temporarily unavailable
We have to run this: sudo fuser -v /var/cache/debconf/config.dat and you’ll see something like this:

USER PID ACCESS COMMAND
/var/cache/debconf/config.dat:
root 5346 F…. frontend
And you have to run sudo kill , where PID is the number above, in this case sudo kill 5346

Finally, run sudo apt-get install -f and then you’ll be able to run sudo apt-get update

Reply
febrian February 6, 2021 - 8:08 pm

Thanks, solution 2 –fix-broken works for me.
I repeatedly Ctrl-C package download because bad internet connection.
It leave me with broken package that cannot be remove nor installed

Reply
Snapchat Models August 30, 2021 - 7:29 am

Thank you for your hard work.

Reply
Ahmed September 26, 2022 - 8:17 am

this is another answer if the sudo or apt dosent run :

$ sudo apt install --fix-broken

$ sudo apt full-upgrade

Reply
test November 3, 2022 - 8:19 am

thanks, method 4 helped

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

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

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More