There are various types of odd errors on servers which actually do not have any common way of fix. Here is One Fix For E: Sub-process /usr/bin/dpkg returned an error code (1) Error Which Makes APT To Fail to Update Packages on Ubuntu 16.04. Inventing the way of error probably helps in fixing similar types of errors. Please carefully read the next each and every sentences.
Before You Proceed For Our Way To Fix E: Sub-process /usr/bin/dpkg returned an error code (1)
Before proceeding to use our way to fix, you must try the common ways described on standard Q&A websites like StackExchange, AskUbuntu. Our way possibly last way and better to be used as last resort.
Fix E: Sub-process /usr/bin/dpkg returned an error code (1)
I am describing what exactly happened in our case. I can
apt update, then
apt upgrade. In the middle of running upgrade the things got broken and started to throw odd errors which has nothing to do with real problem. It was impossible to update, upgrade, install or remove packages in any method we normally know (except brutally deleting everything).
After many trial and error, I understood that the problem is either with the sources as first source of error :
I went to
/etc/apt/sources.list.d and ran
ls, deleted some files with
.save extension, some unnecessary. I opened
/etc/apt/sources.list and commented which are not need or do not have GPG key.
Thereafter I went to
/var/lib/dpkg/info and ran
Then I brutally deleted all the
.postinst files :
Thereafter I ran :
sudo apt-get clean
Thereafter exactly what I needed to perform :
sudo apt update
sudo apt upgrade
I faced no trouble after running the above commands. I really do not know how exactly the commands worked but they worked for me. I hope this guide will be useful to someone in condition like that of me. What I saw from various Q&A sites that experts give importance to the below line on screenshot :
They are :
nsserv: warning: script ‘wide-dhcpv6-client’ missing LSB tags and overrides
insserv: warning: script ‘bind9’ missing LSB tags and overrides
insserv: There is a loop between service nginx and bind9 if stopped
insserv: loop involving service bind9 at depth 2
insserv: loop involving service nginx at depth 1
insserv: loop involving service syslog-ng at depth 4
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header
But, basically their methods not worked for me. Lot of peoples searches how to fix update-rc.d: error: insserv rejected the script header error. I guess my case will help them.