OS: Ubuntu 12.04
dpkg. Now, packages can't be installed. So, needs an
dpkg installer which installs packages.
Download the package complementary to the version of your distro. https://launchpad.net/ubuntu/+source/dpkg/220.127.116.11ubuntu7
Decompress the file.
cd to the root of the dpkg source directory.
./configure make sudo make install
You may need to download some packages if
Depending exactly what you removed, you may be able to rescue the situation by extracting the necessary parts from a manually downloaded
.deb file. The trick, of course, is finding a way to unpack the
.deb file without a working
dpkg - fortunately there's a solution here
First go to packages.ubuntu.com and download the appropriate
.deb file for your OS version and architecture e.g.
mkdir debroot && cd debroot wget http://mirrors.kernel.org/ubuntu/pool/main/d/dpkg/dpkg_1.18.4ubuntu1_amd64.deb
Now unpack the deb file using
ar in place of the usual
ar -x dpkg_1.18.4ubuntu1_amd64.deb
dpkg_1.18.4ubuntu1_amd64.deb with name of the actual deb that you downloaded). You should now have the following contents
control.tar.gz data.tar.gz debian-binary dpkg_1.18.4ubuntu1_amd64.deb
The package's files should be located in the
data.tar.gz so to extract the
dpkg binary file locally
tar xf data.tar.gz ./usr/bin/dpkg
If that worked, you should have a file at
which you can copy to your
sudo cp ./usr/bin/dpkg /usr/bin/
[Note that you could untar the file directly relative to
sudo tar -C ... but doing it in two steps just feels a little safer.]
If that works, I'd recommend re-installing the whole thing from the repository for consistency i.e.
sudo apt-get update sudo apt-get install --reinstall dpkg
(on newer systems, you can replace