OS: Ubuntu 12.04

Accidentally deleted dpkg. Now, packages can't be installed. So, needs an dpkg installer which installs packages.

2 Answers 2


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).

  • Thanks a lot .. You gave me breath as I am dying with frustration... Commented Aug 2, 2020 at 12:58

Download the dpkg package for your release from https://launchpad.net/ubuntu/+source/dpkg/.

Extract 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"... Commented Jun 29, 2016 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
    Commented Sep 20, 2017 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
    Commented Sep 23, 2017 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
    Commented Oct 27, 2017 at 14:22

You must log in to answer this question.

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