info > DPKG

πŸ“¦ NAME

dpkg - package manager for Debian

πŸš€ Quick Reference

Use CaseCommandDescription
Install a .deb packagedpkg -i pkg.debInstall the given package file
Unpack but don't configuredpkg --unpack pkg.debExtract files without running setup scripts
Remove a package (keep config)dpkg -r pkgnameDelete binaries but leave config files
Purge a package (remove all)dpkg -P pkgnameDelete everything including config files
Configure unpacked packagesdpkg --configure pkgnameRun setup scripts for an unpacked package
List matching packagesdpkg -l 'pattern'List installed packages matching shell glob
Show package statusdpkg -s pkgnameDisplay detailed status of a package
List files from a packagedpkg -L pkgnameShow all files installed by the package
Find package owning filedpkg -S /path/to/fileSearch which installed package provides a file
Verify package integritydpkg -V [pkgname]Check md5sums of installed files
Audit package databasedpkg -CCheck for broken or partially installed packages
Add foreign architecturedpkg --add-architecture i386Enable installation of packages for a different arch
Print installed architecturedpkg --print-architectureShow the host architecture (e.g., amd64)
Get/set package selectionsdpkg --get-selections / dpkg --set-selectionsSave/restore package selection state
Compare version numbersdpkg --compare-versions 1.2 lt 2.0Exit 0 if condition true

⚠️ WARNING

This manual is intended for users wishing to understand dpkg's command line options and package states in more detail than that provided by dpkg --help.

It should not be used by package maintainers wishing to understand how dpkg will install their packages. The descriptions of what dpkg does when installing and removing packages are particularly inadequate.

πŸ“‹ DESCRIPTION

dpkg is a medium-level tool to install, build, remove and manage Debian packages. The primary and more user-friendly front-end for dpkg as a CLI (command-line interface) is apt(8) and as a TUI (terminal user interface) is aptitude(8). 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.

dpkg can also be used as a front-end to dpkg-deb(1) and dpkg-query(1). The list of supported actions can be found later on in the ACTIONS section. If any such action is encountered dpkg just 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.

πŸ“Š 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 selection states

🏷️ Package flags

βš™οΈ ACTIONS

-i, --install package-file...

Install the package. If --recursive or -R is specified, package-file must refer to a directory instead.

Installation consists of the following steps:

  1. Extract the control files of the new package.
  2. If another version of the same package was installed before the new installation, execute prerm script of the old package.
  3. Run preinst script, if provided by the package.
  4. Unpack the new files, and at the same time back up the old files, so that if something goes wrong, they can be restored.
  5. If another version of the same package was installed before the new installation, execute the postrm script of the old package. This script is executed after the preinst script of the new package.
  6. Configure the package. See --configure for detailed information.

--unpack package-file...

Unpack the package, but don't configure it. If --recursive or -R is specified, package-file must refer to a directory instead.

--configure package...|-a|--pending

Configure a package which has been unpacked but not yet configured. If -a or --pending is given, all unpacked but unconfigured packages are configured.

To reconfigure a package which has already been configured, try the dpkg-reconfigure(8) command instead.

Configuring consists of the following steps:

  1. Unpack the conffiles, and at the same time back up the old conffiles, so that they can be restored if something goes wrong.
  2. Run postinst script, if provided by the package.

--triggers-only package...|-a|--pending

Processes only triggers (since dpkg 1.14.17). All pending triggers will be processed. If package names are supplied only those packages' triggers will be processed, exactly once each where necessary. Use of this option may leave packages in improper triggers-awaited and triggers-pending states. This can be fixed later by running: dpkg --configure --pending.

-r, --remove package...|-a|--pending

Remove an installed package. This removes everything except conffiles and other data cleaned up by the postrm script, which may avoid having to reconfigure the package if reinstalled later. If there is no DEBIAN/conffiles control file nor DEBIAN/postrm script, this command is equivalent to calling --purge. If -a or --pending is given instead of a package name, then all packages unpacked, but marked to be removed in /var/lib/dpkg/status, are removed.

Removing of a package consists of the following steps:

  1. Run prerm script
  2. Remove the installed files
  3. Run postrm script

-P, --purge package...|-a|--pending

Purge an installed or already removed package. This removes everything, including conffiles, and anything else cleaned up from postrm. If -a or --pending is given instead of a package name, then all packages unpacked or removed, but marked to be purged in /var/lib/dpkg/status, are purged.

Note: Some configuration files might be unknown to dpkg because they are created and handled separately through the configuration scripts. In that case, dpkg won't remove them by itself, but the package's postrm script (which is called by dpkg), has to take care of their removal during purge. Of course, this only applies to files in system directories, not configuration files written to individual users' home directories.

Purging of a package consists of the following steps:

  1. Remove the package, if not already removed. See --remove for detailed information about how this is done.
  2. Run postrm script.

-V, --verify [package-name...]

Verifies the integrity of package-name or all packages if omitted, by comparing information from the files installed by a package with the files metadata information stored in the dpkg database (since dpkg 1.17.2). The origin of the files metadata information in the database is the binary packages themselves. That metadata gets collected at package unpack time during the installation process.

Currently the only functional check performed is an md5sum verification of the file contents against the stored value in the files database. It will only get checked if the database contains the file md5sum. To check for any missing metadata in the database, the --audit command can be used.

The output format is selectable with the --verify-format option, which by default uses the rpm format, but that might change in the future, and as such, programs parsing this command output should be explicit about the format they expect.

-C, --audit [package-name...]

Performs database sanity and consistency checks for package-name or all packages if omitted (per package checks since dpkg 1.17.10). For example, searches for packages that have been installed only partially on your system or that have missing, wrong or obsolete control data or files. dpkg will suggest what to do with them to get them fixed.

--update-avail [Packages-file] / --merge-avail [Packages-file]

Update dpkg's and dselect's idea of which packages are available. With --merge-avail, old information is combined with information from Packages-file. With --update-avail, old information is replaced with the information in the Packages-file. The Packages-file distributed with Debian is simply named Β«PackagesΒ». If the Packages-file argument is missing or named Β«-Β» then it will be read from standard input (since dpkg 1.17.7). dpkg keeps its record of available packages in /var/lib/dpkg/available.

A simpler one-shot command to retrieve and update the available file is dselect update. Note that this file is mostly useless if you don't use dselect but an APT-based frontend: APT has its own system to keep track of available packages.

-A, --record-avail package-file...

Update dpkg and dselect's idea of which packages are available with information from the package package-file. If --recursive or -R option is specified, package-file must refer to a directory instead.

--forget-old-unavail

Now obsolete and a no-op as dpkg will automatically forget uninstalled unavailable packages (since dpkg 1.15.4), but only those that do not contain user information such as package selections.

--clear-avail

Erase the existing information about what packages are available.

--get-selections [package-name-pattern...]

Get list of package selections, and write it to stdout. Without a pattern, non-installed packages (i.e. those which have been previously purged) will not be shown.

--set-selections

Set package selections using file read from stdin. This file should be in the format β€œpackage state”, where state is one of install, hold, deinstall or purge. Blank lines and comment lines beginning with β€˜#’ are also permitted.

The available file needs to be up-to-date for this command to be useful, otherwise unknown packages will be ignored with a warning. See the --update-avail and --merge-avail commands for more information.

--clear-selections

Set the requested state of every non-essential package to deinstall (since dpkg 1.13.18). This is intended to be used immediately before --set-selections, to deinstall any packages not in list given to --set-selections.

--yet-to-unpack

Searches for packages selected for installation, but which for some reason still haven't been installed.

Note: This command makes use of both the available file and the package selections.

--predep-package

Print a single package which is the target of one or more relevant pre-dependencies and has itself no unsatisfied pre-dependencies.

If such a package is present, output it as a Packages file entry, which can be massaged as appropriate.

Note: This command makes use of both the available file and the package selections.

Returns 0 when a package is printed, 1 when no suitable package is available and 2 on error.

--add-architecture architecture

Add architecture to the list of architectures for which packages can be installed without using --force-architecture (since dpkg 1.16.2). The architecture dpkg is built for (i.e. the output of --print-architecture) is always part of that list.

--remove-architecture architecture

Remove architecture from the list of architectures for which packages can be installed without using --force-architecture (since dpkg 1.16.2). If the architecture is currently in use in the database then the operation will be refused, except if --force-architecture is specified. The architecture dpkg is built for (i.e. the output of --print-architecture) can never be removed from that list.

--print-architecture

Print architecture of packages dpkg installs (for example, β€œi386”).

--print-foreign-architectures

Print a newline-separated list of the extra architectures dpkg is configured to allow packages to be installed for (since dpkg 1.16.2).

--assert-help

Give help about the --assert-feature options (since dpkg 1.21.0).

--assert-feature

Asserts that dpkg supports the requested feature. Returns 0 if the feature is fully supported, 1 if the feature is known but dpkg cannot provide support for it yet, and 2 if the feature is unknown. The current list of assertable features is:

--validate-thing string

Validate that the thing string has a correct syntax (since dpkg 1.18.16). Returns 0 if the string is valid, 1 if the string is invalid but might be accepted in lax contexts, and 2 if the string is invalid. The current list of validatable things is:

--compare-versions ver1 op ver2

Compare version numbers, where op is a binary operator. dpkg returns true (0) if the specified condition is satisfied, and false (1) otherwise. There are two groups of operators:

-?, --help

Display a brief help message.

--force-help

Give help about the --force-thing options.

-Dh, --debug=help

Give help about debugging options.

--version

Display dpkg version information. When used with --robot, the output will be the program version number in a dotted numerical format, with no newline.

dpkg-deb actions

See dpkg-deb(1) for more information about the following actions, and other actions and options not exposed by the dpkg front-end.

dpkg-query actions

See dpkg-query(1) for more information about the following actions, and other actions and options not exposed by the dpkg front-end.

πŸ”§ 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 hyphens) or a comment (if it starts with a #).

--abort-after=number

Change after how many errors dpkg will abort. The default is 50.

-B, --auto-deconfigure

When a package is removed, there is a possibility that another installed package depended on the removed package. Specifying this option will cause automatic deconfiguration of the package which depended on the removed package.

-Doctal, --debug=octal

Switch debugging on. octal is formed by bitwise-ORing desired values together from the list below (note that these values may change in future releases). -Dh or --debug=help display these debugging values.

NumberDescription
1Generally helpful progress information
2Invocation and status of maintainer scripts
10Output for each file processed
100Lots of output for each file processed
20Output for each configuration file
200Lots of output for each configuration file
40Dependencies and conflicts
400Lots of dependencies/conflicts output
10000Trigger activation and processing
20000Lots of output regarding triggers
40000Silly amounts of output regarding triggers
1000Lots of drivel about e.g. the dpkg/info dir
2000Insane amounts of drivel

--force-things, --no-force-things, --refuse-things

Force or refuse (no-force and refuse mean the same thing) to do some things. things is a comma separated list of things specified below. --force-help displays a message describing them. Things marked with (*) are forced by default.

Warning: These options are mostly intended to be used by experts only. Using them without fully understanding their effects may break your whole system.

--ignore-depends=package,...

Ignore dependency-checking for specified packages (actually, checking is performed, but only warnings about conflicts are given, nothing else). This affects the Pre-Depends, Depends and Breaks fields.

--no-act, --dry-run, --simulate

Do everything which is supposed to be done, but don't write any changes. This is used to see what would happen with the specified action, without actually modifying anything.

Be sure to give --no-act before the action-parameter, or you might end up with undesirable results. (e.g. dpkg --purge foo --no-act will first purge package β€œfoo” and then try to purge package ”--no-act”, even though you probably expected it to actually do nothing).

-R, --recursive

Recursively handle all regular files matching pattern *.deb found at specified directories and all of its subdirectories. This can be used with -i, -A, --install, --unpack and --record-avail actions.

-G

Don't install a package if a newer version of the same package is already installed. This is an alias of --refuse-downgrade.

--admindir=dir

Set the administrative directory to directory. This directory contains many files that give information about status of installed or uninstalled packages, etc. Defaults to Β«/var/lib/dpkgΒ».

--instdir=dir

Set the installation directory, which refers to the directory where packages are to be installed. instdir is also the directory passed to chroot(2) before running package's installation scripts, which means that the scripts see instdir as a root directory. Defaults to Β«/Β».

--root=dir

Set the root directory to directory, which sets the installation directory to Β«dirΒ» and the administrative directory to Β«dir/var/lib/dpkgΒ».

-O, --selected-only

Only process the packages that are selected for installation. The actual marking is done with dselect or by dpkg, when it handles packages. For example, when a package is removed, it will be marked selected for deinstallation.

-E, --skip-same-version

Don't install the package if the same version of the package is already installed.

--pre-invoke=command / --post-invoke=command

Set an invoke hook command to be run via β€œsh -c” before or after the dpkg run for the unpack, configure, install, triggers-only, remove, purge, add-architecture and remove-architecture dpkg actions (since dpkg 1.15.4; add-architecture and remove-architecture actions since dpkg 1.17.19). This option can be specified multiple times. The order the options are specified is preserved, with the ones from the configuration files taking precedence. The environment variable DPKG_HOOK_ACTION is set for the hooks to the current dpkg action.

Note: Front-ends might call dpkg several times per invocation, which might run the hooks more times than expected.

--path-exclude=glob-pattern / --path-include=glob-pattern

Set glob-pattern as a path filter, either by excluding or re-including previously excluded paths matching the specified patterns during install (since dpkg 1.15.8).

Warning: Take into account that depending on the excluded paths you might completely break your system, use with caution.

The glob patterns use the same wildcards used in the shell, were β€˜*’ matches any sequence of characters, including the empty string and also β€˜/’. For example, Β«/usr/*/READ*Β» matches Β«/usr/share/doc/package/READMEΒ». As usual, β€˜?’ matches any single character (again, including β€˜/’). And β€˜[’ starts a character class, which can contain a list of characters, ranges and complementations. See glob(7) for detailed information about globbing. Note: The current implementation might re-include more directories and symlinks than needed, in particular when there is a more specific re-inclusion, to be on the safe side and avoid possible unpack failures; future work might fix this.

This can be used to remove all paths except some particular ones; a typical case is:

--path-exclude=/usr/share/doc/*
--path-include=/usr/share/doc/*/copyright

to remove all documentation files except the copyright files.

These two options can be specified multiple times, and interleaved with each other. Both are processed in the given order, with the last rule that matches a file name making the decision.

The filters are applied when unpacking the binary packages, and as such only have knowledge of the type of object currently being filtered (e.g. a normal file or a directory) and have not visibility of what objects will come next. Because these filters have side effects (in contrast to find(1) filters), excluding an exact pathname that happens to be a directory object like /usr/share/doc will not have the desired result, and only that pathname will be excluded (which could be automatically reincluded if the code sees the need). Any subsequent files contained within that directory will fail to unpack.

Hint: make sure the globs are not expanded by your shell.

--verify-format format-name

Sets the output format for the --verify command (since dpkg 1.17.2).

The only currently supported output format is rpm, which consists of a line for every path that failed any check. These lines have the following format:

missing   [c] pathname [(error-message)]
??5?????? [c] pathname

The first 9 characters are used to report the checks result, either a literal missing when the file is not present or its metadata cannot be fetched, or one of the following special characters that report the result for each check:

The line is followed by a space and an attribute character. The following attribute character is supported:

Finally followed by another space and the pathname.

In case the entry was of the missing type, and the file was not actually present on the filesystem, then the line is followed by a space and the error message enclosed within parenthesis.

--status-fd n

Send machine-readable package status and progress information to file descriptor n. This option can be specified multiple times. The information is generally one record per line, in one of the following forms:

status: package: status                  # Package status changed; status as in status file
status: package : error : extended-error # Error occurred; any newlines converted to spaces
status: file : conffile-prompt : 'real-old' 'real-new' useredited distedited  # Conffile question
processing: stage: package               # Start of a processing stage (upgrade, install, configure, trigproc, disappear, remove, purge)

--status-logger=command

Send machine-readable package status and progress information to the shell command's standard input, to be run via β€œsh -c” (since dpkg 1.16.0). This option can be specified multiple times. The output format used is the same as in --status-fd.

--log=filename

Log status change updates and actions to filename, instead of the default /var/log/dpkg.log. If this option is given multiple times, the last filename is used. Log messages are of the form:

YYYY-MM-DD HH:MM:SS startup type command        # type: archives (unpack/install) or packages (configure,triggers-only,remove,purge)
YYYY-MM-DD HH:MM:SS status state pkg installed-version   # status change updates
YYYY-MM-DD HH:MM:SS action pkg installed-version available-version  # install, upgrade, configure, trigproc, disappear, remove, purge
YYYY-MM-DD HH:MM:SS conffile filename decision   # decision: install or keep

--robot

Use a machine-readable output format. This provides an interface for programs that need to parse the output of some of the commands that do not otherwise emit a machine-readable output format. No localization will be used, and the output will be modified to make it easier to parse.

The only currently supported command is --version.

--no-pager

Disables the use of any pager when showing information (since dpkg 1.19.2).

--no-debsig

Do not try to verify package signatures.

--no-triggers

Do not run any triggers in this run (since dpkg 1.14.17), but activations will still be recorded. If used with --configure package or --triggers-only package then the named package postinst will still be run even if only a triggers run is needed. Use of this option may leave packages in the improper triggers-awaited and triggers-pending states. This can be fixed later by running: dpkg --configure --pending.

--triggers

Cancels a previous --no-triggers (since dpkg 1.14.17).

πŸšͺ EXIT STATUS

🌍 ENVIRONMENT

External environment

Internal environment (set by dpkg for maintainer scripts)

πŸ“ FILES

The format and contents of a binary package are described in deb(5).

🐞 BUGS

--no-act usually gives less information than might be helpful.

πŸ“ EXAMPLES

List installed packages related to vi

dpkg -l '*vi*'

Note that dpkg-query does not load the available file anymore by default; use dpkg-query --load-avail for that.

See available entries for two packages

dpkg --print-avail elvis vim | less

Or search manually:

less /var/lib/dpkg/available

Remove an installed package

dpkg -r elvis

Install a package from CDROM

cd /media/cdrom/pool/main/v/vim
dpkg -i vim_4.5-3.deb

Save and restore package selections

Save current selections:

dpkg --get-selections > myselections

On another computer, update the available file (example with apt-cache):

apt-cache dumpavail | dpkg --merge-avail

Then clear and set selections:

dpkg --clear-selections
dpkg --set-selections < myselections

This only sets the selection state; you still need to actually install/remove packages, e.g., with apt-get dselect-upgrade.

Ordinarily, dselect(1) provides a more convenient way to modify the package selection states.

βž• ADDITIONAL FUNCTIONALITY

Additional functionality can be gained by installing any of the following packages: apt, aptitude and debsums.

πŸ“– SEE ALSO

πŸ‘₯ AUTHORS

See /usr/share/doc/dpkg/THANKS for the list of people who have contributed to dpkg.


πŸ“¦ NAME: Dpkg - module with core variables

πŸš€ Quick Reference (Dpkg Perl module)

Use CaseExpressionDescription
Get current program name$Dpkg::PROGNAMEName of the running program
Get dpkg suite version$Dpkg::PROGVERSIONVersion string of the dpkg suite
Get path to GNU make$Dpkg::PROGMAKEFull path to the make program
Get path to GNU tar$Dpkg::PROGTARFull path to tar
Get path to patch$Dpkg::PROGPATCHFull path to GNU patch (or safe alternative)
Get configuration directory$Dpkg::CONFDIRSystem dpkg config directory
Get database directory$Dpkg::ADMINDIRPath to /var/lib/dpkg
Get methods/plugins dir$Dpkg::LIBDIRDirectory for dpkg methods and plugins
Get arch tables directory$Dpkg::DATADIRPath to architecture tables

πŸ“‹ DESCRIPTION

The Dpkg module provides a set of variables with information concerning this system installation. It is also the entry point to the Dpkg module hierarchy.

πŸ“Š VARIABLES

🧩 MODULES

The following is the list of public modules within the Dpkg hierarchy. Only modules with versions 1.00 or higher, and only the interfaces documented in their POD are considered public.

πŸ“ CHANGES

Version 2.00 (dpkg 1.20.0)

Remove variables: $version, $progname, $admindir, $dpkglibdir and $pkgdatadir.

Version 1.03 (dpkg 1.18.24)

New variable: $PROGPATCH.

Version 1.02 (dpkg 1.18.11)

New variables: $PROGTAR, $PROGMAKE.

Version 1.01 (dpkg 1.17.0)

New variables: $PROGNAME, $PROGVERSION, $CONFDIR, $ADMINDIR, $LIBDIR and $DATADIR.
Deprecated variables: $version, $admindir, $dpkglibdir and $pkgdatadir.

Version 1.00 (dpkg 1.15.6)

Mark the module as public.

πŸ“œ LICENSE

See the header comment on each module for their particular license.

DPKG
πŸ“¦ NAME πŸš€ Quick Reference ⚠️ WARNING πŸ“‹ DESCRIPTION πŸ“Š INFORMATION ABOUT PACKAGES
πŸ“¦ Package states βœ… Package selection states 🏷️ Package flags
βš™οΈ ACTIONS
-i, --install package-file... --unpack package-file... --configure package...|-a|--pending --triggers-only package...|-a|--pending -r, --remove package...|-a|--pending -P, --purge package...|-a|--pending -V, --verify [package-name...] -C, --audit [package-name...] --update-avail [Packages-file] / --merge-avail [Packages-file] -A, --record-avail package-file... --forget-old-unavail --clear-avail --get-selections [package-name-pattern...] --set-selections --clear-selections --yet-to-unpack --predep-package --add-architecture architecture --remove-architecture architecture --print-architecture --print-foreign-architectures --assert-help --assert-feature --validate-thing string --compare-versions ver1 op ver2 -?, --help --force-help -Dh, --debug=help --version dpkg-deb actions dpkg-query actions
πŸ”§ OPTIONS
--abort-after=number -B, --auto-deconfigure -Doctal, --debug=octal --force-things, --no-force-things, --refuse-things --ignore-depends=package,... --no-act, --dry-run, --simulate -R, --recursive -G --admindir=dir --instdir=dir --root=dir -O, --selected-only -E, --skip-same-version --pre-invoke=command / --post-invoke=command --path-exclude=glob-pattern / --path-include=glob-pattern --verify-format format-name --status-fd n --status-logger=command --log=filename --robot --no-pager --no-debsig --no-triggers --triggers
πŸšͺ EXIT STATUS 🌍 ENVIRONMENT
External environment Internal environment (set by dpkg for maintainer scripts)
πŸ“ FILES 🐞 BUGS πŸ“ EXAMPLES
List installed packages related to vi See available entries for two packages Remove an installed package Install a package from CDROM Save and restore package selections
βž• ADDITIONAL FUNCTIONALITY πŸ“– SEE ALSO πŸ‘₯ AUTHORS πŸ“¦ NAME: Dpkg - module with core variables πŸš€ Quick Reference (Dpkg Perl module) πŸ“‹ DESCRIPTION πŸ“Š VARIABLES 🧩 MODULES πŸ“ CHANGES
Version 2.00 (dpkg 1.20.0) Version 1.03 (dpkg 1.18.24) Version 1.02 (dpkg 1.18.11) Version 1.01 (dpkg 1.17.0) Version 1.00 (dpkg 1.15.6)
πŸ“œ LICENSE

Generated by phpman v4.9.26-1-g511901d · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-08-09 10:21 @2600:1f28:365:80b0:50b3:453e:ff52:20f7
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format

^_top_^