Fix E: Sub-process /usr/bin/dpkg returned an error code (1)

Advertisement

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 :

Vim

1

2

/etc/apt/sources.list.d

/etc/apt/sources.list

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 ls :

Vim

1

2

cd/var/lib/dpkg/info

ls

Then I brutally deleted all the .postinst files :

Vim

1

rm*.postinst

Advertisement

---

Thereafter I ran :

Vim

1

sudo apt-get clean

Thereafter exactly what I needed to perform :

Vim

1

2

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 :