If you want to know how to remove E: Sub-process /usr/bin/dpkg returned an error code (1), which is printed at the bottom, whenever you try to update, install, or remove it, read this guide.
E: Sub-process /usr/bin/dpkg returned an error code (1). is a common problem that many users encounter while managing the software on their Linux distributions.
This error happens when the computer’s package management system (dpkg) runs into a problem while installing, updating, or removing software.
It can be caused by many things, including corrupted files, broken dependencies, a lack of disk space or system resources, or an incorrect package configuration.
To fix this issue, users should check the package manager’s log file for more detailed information about the exact nature of the problem and once you know the cause of the issue, you can resolve it very easily.
The purpose of this article is not to find out exactly what caused the error above, but I will give you some tips and commands that you can use to fix the “sub-process /usr/bin/dpkg returned an error code (1).”
Table of Contents
Some of the common solutions to resolve the dpkg error
It’s important to remember that this error code doesn’t always mean something is wrong, so the user shouldn’t panic. Instead, you should simply follow the steps in this article to fix it.
Reconfigure the dpkg database
One reason for the above error is that the dpkg database got messed up or corrupted because the installation or removal of the application got interrupted during the process.
So, the first thing to try is to reconfigure the dpkg database, which will help rebuild the database and hopefully resolve the error.
To do this, you need to open the Terminal window and enter the command, which is described below.
$ sudo dpkg --configure -a
The output of the above command made it clear that it is an issue related to “onlyoffice-documentserver” and the cause is “can’t connect to postgressql database,” so to fix this issue I can take further steps, which may not be useful for you, so I’m omitting this step.
If your problem is solved, then you are good to go, but if you are still stuck, then it is time to try out a more involved solution.
Force install package
If an application’s installation is interrupted for any reason, you can always force it to finish by using the apt command with the -f or --fix-broken option, which will attempt to repair and complete the interrupted installation process.
Here is an example of how you would use this command:
$ sudo apt install -f
$ sudo apt install --fix-broken
If the problem still persists, then the last resort is to remove the broken package script from the /var/lib/dpkg/info directory, which you will learn how to do in the next section.
Remove package script from /var/lib/dpkg/info
If you know the name of the conflicting package, you should try to remove the wrong package script from the /var/lib/dpkg/info directory by running the following command in the terminal:
$ sudo rm -rf /var/lib/dpkg/info/<package-name>.*
On my part, I’ll use the same command syntax to remove the conflict package that is partially installed, and, because of that, I’m not able to use or remove the application from my system, so to fix this, I’ll type:
$ sudo rm -rf /var/lib/dpkg/info/onlyoffice-documentserver.*
After that, you can try to uninstall the package from your system by running the following command:
$ sudo apt remove --purge <package-name>
Then you run the following command to remove the unused and unnecessary package from your system:
$ sudo apt clean
$ sudo apt autoremove
Congratulations on successfully resolving the issue.
That’s all it takes to fix “Sub-process /usr/bin/dpkg returned an error code (1)” on Debian, Ubuntu, or any other Ubuntu derivative. If the above method worked, you can be sure that you understand the problem and the steps you need to take to fix it.
If you know any other way to fix the issue, please let us know in the comment section so you can help others with the same problem.
Till then, put your feet up and relax. As always, the next article will be up shortly.
A man with a tech effusive who has explored some of the amazing technology stuff and is exploring more. While moving towards, I had a chance to work on Android development, Linux, AWS, and DevOps with several open-source tools.