On Linux operating systems that use Debian package management, the dpkg command queries, installs, removes, and maintains Debian software packages and their dependencies.

Description

The primary and more user-friendly front-end for dpkg is aptitude. dpkg itself is controlled entirely via command line parameters, which consist of exactly one action and zero or more options. The action parameter tells dpkg what to do and options control the behavior of the action in some way.

  • Description
  • Syntax
  • Information about packages
  • Environment
  • Examples
  • Linux commands help

dpkg can also be used as a front-end to dpkg-deb and dpkg-query. The list of supported actions is below (in the “Actions” section). If any such action is encountered, dpkg runs dpkg-deb or dpkg-query with the parameters given to it, but no specific options are currently passed to them. To use any such option, the back-ends need to be called directly.

Syntax

dpkg [option…] action

Actions

Options

All options can be specified both on the command line and in the dpkg configuration file /etc/dpkg/dpkg.cfg or fragment files (with names matching this shell pattern ‘[0-9a-zA-Z_-]*’) on the configuration directory /etc/dpkg/dpkg.cfg.d/. Each line in the configuration file is either an option (exactly the same as the command line option but without leading dashes) or a comment (if it starts with a #).

Information about packages

dpkg maintains some usable information about available packages. The information is divided in three classes: states, selection states and flags. These values are intended to be changed mainly with dselect.

Package states

Package installation states

Package flags

Files

The other files listed below are in their default directories. See option –admindir to see how to change locations of these files.

Additionally, the following files are components of a binary package: control, conffiles, preinst, postinst, prerm, and postrm.

Environment

Examples

dpkg -l ‘vi

List installed packages related to the editor vi.

dpkg –print-avail elvis vim | less

View the entries of the packages elvis and vim as listed in /var/lib/dpkg/available.

less /var/lib/dpkg/available

Manually view the list of available software packages.

dpkg -r elvis

Remove the installed package elvis.

dpkg -i vim_4.5-3.deb

Install the package contained in the file vim_4.5-3.deb.

dpkg –get-selections >myselections

Make a local copy of the package selection states.