My question is simple -- I want to know more about dpkg -- what does it do?

  • This has been edited at least twice to improve clarity -- as it stands it might be worth keeping open (provided it isn't a duplicate) because it has generated at least one good answer. – belacqua Aug 9 '12 at 1:47
  • 1
    you should visit first : en.wikipedia.org/wiki/Dpkg – Pandya Jun 18 '15 at 10:36

As has been said, dpkg is a low-level system tool to extract, analyse, unpack and install or remove .deb files. However, it is better to use Software Centre or Gdebi to install or remove .deb files that have been gained from other sources because these two programs have dependency resolution.

However, what has not been explained is the anatomy of an update using dpkg and apt-get. If, for example we call apt-get to install cheese, the dependency tree is analysed and the necessary files are fetched by apt-get, which then passes them to dpkg to extract, analyse and install to the correct locations and configure them according to the scripts inside them.

The scripts read by dpkg inside each .deb file are important as they give information to the program regarding the packages' installation, removal and configuration. Hence when you look in /var/log/dpkg.log there are a lot of verbose details about 'triggers' and packages going through varying stages of unpacking and configuration. In his blog, Raphael Hertzog (who is a key Debian developer and maintainer of the dpkg package) explains more about dpkg triggers and the way dpkg inspects and configures packages.

We are now getting to the heart of what dpkg does; it expertly handles Debian packages, rather than their dependencies. With dpkg-deb, for example, you can perform various actions in analysing and manually extracting files from the .deb archives; see man dpkg-deb for further information.

The status of each package is listed in /var/lib/dpkg/status, which can be used with grep to check on a particular package. Dpkg can also be called to reconfigure particular packages that have been configured (see man dpkg-reconfigure):

sudo dpkg-reconfigure <package>

Or to do a configuring of all unconfigured packages if there has been a problem with an update and some packages' configuration is still pending:

sudo dpkg --configure -a

For a great tutorial that focuses on dpkg and apt-get, see chapters 5 and 6 of the Debian Handbook, which is the best discussion available. Enter man dpkg in your terminal or view the Ubuntu manpages online to see all the many options available, such as using dpkg -l to list currently installed packages.


dpkg is a command line way to install from a .deb or remove already installed packages. For example if you had a .deb file in your home directory, running dpkg -i yourpackage.deb will install that package for you. I find this useful atleast for me because sometimes when clicking on a .deb file it loads the Ubuntu Software Center but never really installs it or has problems.


As always, the man command is a great place to start.
man dpkg can give you all options, nevertheless:

dpkg is a package manager for Debian-based systems. It can install, remove, and build packages, but unlike other package management systems it can not automatically download and install packages and their dependencies.

So basically it's apt-get without dependency resolving, and it's used to install .deb files.

I warn you though: Uninstalling packages using dpkg, in most cases, is NOT recommended. It is better to use a package manager that handles dependencies, to ensure that the system is in a consistent state.

For example using dpkg -r zip you can remove the zip package, but any packages that depend on it will still be installed and may no longer function correctly.

You can read some more about it in the server guide, and elsewhere.

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.