13

By mistake I have removed dpkg from my pc (ubuntu 16.04). When I am running apt commands, it was showing error :

Could not exec dpkg!
E: Sub-process /usr/bin/dpkg returned an error code (100)

Can anyone suggest me any solution to this. Thanks in advance !!!

2
  • 1
    Wait - did you remove the entire package or just the binary? Oct 25, 2016 at 21:14
  • 4
    How did you remove dpkg ? which command did you use ? Oct 25, 2016 at 23:18

1 Answer 1

18

To fix this, open a terminal and download the dpkg Install dpkg package:

# For i386:
wget http://mirrors.kernel.org/ubuntu/pool/main/d/dpkg/dpkg_1.18.4ubuntu1_i386.deb
# For amd64
wget http://mirrors.kernel.org/ubuntu/pool/main/d/dpkg/dpkg_1.18.4ubuntu1_amd64.deb

The versions will differ for different Ubuntu releases. If apt-get is still available (only dpkg was removed), you can still use apt-get to just download the appropriate version:

apt-get download dpkg

Or you can use https://packages.ubuntu.com/dpkg to get a download link for your Ubuntu release and architecture.

Extract the data.tar.gz file from the .deb file, which is actually an ar archive:

ar x dpkg_*.deb

Extract the package contents from data.tar.gz into the filesystem:

sudo tar xf data.tar.gz -C / .

Note: this will get just enough of dpkg working to let you use it. Be sure to install the dpkg package afterwards:

sudo apt-get install --reinstall dpkg
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .