OS: Ubuntu 12.04

Accidentally deleted 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/

Decompress the file.

cd to the root of the dpkg source directory.



sudo make install

You may need to download some packages if ./configure fails

  • when I type "./configure" it says something and in end of them: "configure: error: no curses library found"... – Mohammad Mahdi Naderi Jun 29 '16 at 14:40
  • This doesn't actually explain anything and it doesn't work currently. ./configure requires a bunch of things and it's unclear what exactly it wants. – G_V Sep 20 '17 at 12:34
  • 1
    @G_V If you have a new question, I's sure someone would love to provide a lengthy explanation. Post your configure errors to your new question. It sounds like you need to install some packages to get dpkg to work. – j0h Sep 23 '17 at 2:46
  • @j0h I ended up doing a repair install of my OS partition, less hassle. I didn't really understand what ./configure was for or what make really did since I had never installed anything via make before. This link helped to understand what was actually going on. – G_V Oct 27 '17 at 14:22

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

How to extract and install .deb without the command dpkg?

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 dpkg -x

ar -x dpkg_1.18.4ubuntu1_amd64.deb

(replace 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 ./usr/bin/dpkg which you can copy to your /usr/bin directory

sudo cp ./usr/bin/dpkg /usr/bin/

[Note that you could untar the file directly relative to / using 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 apt-get by apt).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.