Linux "dpkg" Command Line Options and Examples
package manager for Debian

dpkg is a tool to install, build, remove and manage Debian packages. The primary and more user-friendly front-end for dpkg is aptitude(1). dpkg itself is controlled entirely via command line parameters, which consist of exactly one action and zero or more options.


Usage:

dpkg [option...] action






Command Line Options:

--abort-after
Change after how many errors dpkg will abort. The default is 50.
dpkg --abort-after ...
-B
When a package is removed, there is a possibility that another installed package depended on the removed package. Specifyingthis option will cause automatic deconfiguration of the package which depended on the removed package.
dpkg -B ...
-Doctal
Switch debugging on. octal is formed by bitwise-oring desired values together from the list below (note that these values maychange in future releases). -Dh or --debug=help display these debugging values.Number Description1 Generally helpful progress information2 Invocation and status of maintainer scripts10 Output for each file processed100 Lots of output for each file processed20 Output for each configuration file200 Lots of output for each configuration file40 Dependencies and conflicts400 Lots of dependencies/conflicts output10000 Trigger activation and processing20000 Lots of output regarding triggers40000 Silly amounts of output regarding triggers1000 Lots of drivel about e.g. the dpkg/info dir2000 Insane amounts of drivel
dpkg -Doctal ...
--no-force-things
Force or refuse (no-force and refuse mean the same thing) to do some things. things is a comma separated list of thingsspecified 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 effectsmay break your whole system.all: Turns on (or off) all force options.downgrade(*): Install a package, even if newer version of it is already installed.Warning: At present dpkg does not do any dependency checking on downgrades and therefore will not warn you if the downgradebreaks the dependency of some other package. This can have serious side effects, downgrading essential system components caneven make your whole system unusable. Use with care.configure-any: Configure also any unpacked but unconfigured packages on which the current package depends.hold: Process packages even when marked “hold”.remove-reinstreq: Remove a package, even if it's broken and marked to require reinstallation. This may, for example, causeparts of the package to remain on the system, which will then be forgotten by dpkg.remove-essential: Remove, even if the package is considered essential. Essential packages contain mostly very basic Unixcommands. Removing them might cause the whole system to stop working, so use with caution.depends: Turn all dependency problems into warnings.depends-version: Don't care about versions when checking dependencies.breaks: Install, even if this would break another package (since dpkg 1.14.6).conflicts: Install, even if it conflicts with another package. This is dangerous, for it will usually cause overwriting ofsome files.confmiss: Always install the missing conffile without prompting. This is dangerous, since it means not preserving a change(removing) made to the file.confnew: If a conffile has been modified and the version in the package did change, always install the new version withoutprompting, unless the --force-confdef is also specified, in which case the default action is preferred.confold: If a conffile has been modified and the version in the package did change, always keep the old version withoutprompting, unless the --force-confdef is also specified, in which case the default action is preferred.confdef: If a conffile has been modified and the version in the package did change, always choose the default action withoutprompting. If there is no default action it will stop to ask the user unless --force-confnew or --force-confold is also beengiven, in which case it will use that to decide the final action.confask: If a conffile has been modified always offer to replace it with the version in the package, even if the version inthe package did not change (since dpkg 1.15.8). If any of --force-confnew, --force-confold, or --force-confdef is also given,it will be used to decide the final action.overwrite: Overwrite one package's file with another's file.overwrite-dir: Overwrite one package's directory with another's file.overwrite-diverted: Overwrite a diverted file with an undiverted version.unsafe-io: Do not perform safe I/O operations when unpacking (since dpkg 1.15.8.6). Currently this implies not performingfile system syncs before file renames, which is known to cause substantial performance degradation on some file systems,unfortunately the ones that require the safe I/O on the first place due to their unreliable behaviour causing zero-lengthfiles on abrupt system crashes.Note: For ext4, the main offender, consider using instead the mount option nodelalloc, which will fix both the performancedegradation and the data safety issues, the latter by making the file system not produce zero-length files on abrupt systemcrashes with any software not doing syncs before atomic renames.Warning: Using this option might improve performance at the cost of losing data, use with care.script-chrootless: Run maintainer scrips without chroot(2)ing into instdir even if the package does not support this mode ofoperation (since dpkg 1.18.5).Warning: This can destroy your host system, use with extreme care.architecture: Process even packages with wrong or no architecture.bad-version: Process even packages with wrong versions (since dpkg 1.16.1).bad-path: PATH is missing important programs, so problems are likely.not-root: Try to (de)install things even when not root.bad-verify: Install a package even if it fails authenticity check.
dpkg --no-force-things ...
--ignore-depends
Ignore dependency-checking for specified packages (actually, checking is performed, but only warnings about conflicts aregiven, nothing else).
dpkg --ignore-depends ...
--no-act
Do everything which is supposed to be done, but don't write any changes. This is used to see what would happen with thespecified 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
dpkg --no-act ...
-R
Recursively handle all regular files matching pattern *.deb found at specified directories and all of its subdirectories. Thiscan be used with -i, -A, --install, --unpack and --record-avail actions.
dpkg -R ...
-G
Don't install a package if a newer version of the same package is already installed. This is an alias of --refuse-downgrade.
dpkg -G ...
--admindir
Change default administrative directory, which contains many files that give information about status of installed oruninstalled packages, etc. (Defaults to «/var/lib/dpkg»)
dpkg --admindir ...
--instdir
Change default installation directory which refers to the directory where packages are to be installed. instdir is also thedirectory passed to chroot(2) before running package's installation scripts, which means that the scripts see instdir as aroot directory. (Defaults to «/»)
dpkg --instdir ...
--root
Changing root changes instdir to «dir» and admindir to «dir/var/lib/dpkg».
dpkg --root ...
-O
Only process the packages that are selected for installation. The actual marking is done with dselect or by dpkg, when ithandles packages. For example, when a package is removed, it will be marked selected for deinstallation.
dpkg -O ...
-E
Don't install the package if the same version of the package is already installed.
dpkg -E ...
--post-invoke
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 andremove-architecture actions since dpkg 1.17.19). This option can be specified multiple times. The order the options arespecified is preserved, with the ones from the configuration files taking precedence. The environment variableDPKG_HOOK_ACTION is set for the hooks to the current dpkg action. Note: front-ends might call dpkg several times perinvocation, which might run the hooks more times than expected.
dpkg --post-invoke ...
--path-include
Set glob-pattern as a path filter, either by excluding or re-including previously excluded paths matching the specifiedpatterns 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 emptystring and also ‘/’. For example, «/usr/*/READ*» matches «/usr/share/doc/package/README». As usual, ‘?’ matches any singlecharacter (again, including ‘/’). And ‘[’ starts a character class, which can contain a list of characters, ranges andcomplementations. See glob(7) for detailed information about globbing. Note: the current implementation might re-include moredirectories and symlinks than needed, 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:
dpkg --path-include ...
--verify-format
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. The linesstart with 9 characters to report each specific check result, a ‘?’ implies the check could not be done (lack of support, filepermissions, etc), ‘.’ implies the check passed, and an alphanumeric character implies a specific check failed; the md5sumverification failure (the file contents have changed) is denoted with a ‘5’ on the third character. The line is followed by aspace and an attribute character (currently ‘c’ for conffiles), another space and the pathname.
dpkg --verify-format ...
--status-fd
Send machine-readable package status and progress information to file descriptor n. This option can be specified multipletimes. The information is generally one record per line, in one of the following forms:status: package: statusPackage status changed; status is as in the status file.status: package : error : extended-error-messageAn error occurred. Any possible newlines in extended-error-message will be converted to spaces before output.status: file : conffile-prompt : 'real-old' 'real-new' useredited disteditedUser is being asked a conffile question.processing: stage: packageSent just before a processing stage starts. stage is one of upgrade, install (both sent before unpacking), configure,trigproc, disappear, remove, purge.
dpkg --status-fd ...
--status-logger
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.
dpkg --status-logger ...
--log
Log status change updates and actions to filename, instead of the default /var/log/dpkg.log. If this option is given multipletimes, the last filename is used. Log messages are of the form:YYYY-MM-DD HH:MM:SS startup type commandFor each dpkg invocation where type is archives (with a command of unpack or install) or packages (with a command ofconfigure, triggers-only, remove or purge).YYYY-MM-DD HH:MM:SS status state pkg installed-versionFor status change updates.YYYY-MM-DD HH:MM:SS action pkg installed-version available-versionFor actions where action is one of install, upgrade, configure, trigproc, disappear, remove or purge.YYYY-MM-DD HH:MM:SS conffile filename decisionFor conffile changes where decision is either install or keep.
dpkg --log ...
--no-debsig
Do not try to verify package signatures.
dpkg --no-debsig ...
--no-triggers
Do not run any triggers in this run (since dpkg 1.14.17), but activations will still be recorded. If used with --configurepackage 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 byrunning: dpkg --configure --pending.
dpkg --no-triggers ...
--triggers
Cancels a previous --no-triggers (since dpkg 1.14.17).EXIT STATUS0 The requested action was successfully performed. Or a check or assertion command returned true.1 A check or assertion command returned false.2 Fatal or unrecoverable error due to invalid command-line usage, or interactions with the system, such as accesses to thedatabase, memory allocations, etc.ENVIRONMENTExternal environmentPATH This variable is expected to be defined in the environment and point to the system paths where several required programs areto be found. If it's not set or the programs are not found, dpkg will abort.HOME If set, dpkg will use it as the directory from which to read the user specific configuration file.TMPDIR If set, dpkg will use it as the directory in which to create temporary files and directories.PAGER The program dpkg will execute when displaying the conffiles.SHELL The program dpkg will execute when starting a new interactive shell.COLUMNSSets the number of columns dpkg should use when displaying formatted text. Currently only used by --list.DPKG_COLORSSets the color mode (since dpkg 1.18.5). The currently accepted values are: auto (default), always and never.Internal environmentDPKG_ROOTDefined by dpkg on the maintainer script environment to indicate which installation to act on (since dpkg 1.18.5). The valueis intended to be prepended to any path maintainer scripts operate on. During normal operation, this variable is empty. Wheninstalling packages into a different instdir, dpkg normally invokes maintainer scripts using chroot(2) and leaves thisvariable empty, but if --force-script-chrootless is specified then the chroot(2) call is skipped and instdir is non-empty.DPKG_ADMINDIRDefined by dpkg on the maintainer script environment to indicate the dpkg administrative directory to use (since dpkg 1.16.0).This variable is always set to the current --admindir value.DPKG_SHELL_REASONDefined by dpkg on the shell spawned on the conffile prompt to examine the situation (since dpkg 1.15.6). Current validvalue: conffile-prompt.DPKG_CONFFILE_OLDDefined by dpkg on the shell spawned on the conffile prompt to examine the situation (since dpkg 1.15.6). Contains the pathto the old conffile.DPKG_CONFFILE_NEWDefined by dpkg on the shell spawned on the conffile prompt to examine the situation (since dpkg 1.15.6). Contains the pathto the new conffile.DPKG_HOOK_ACTIONDefined by dpkg on the shell spawned when executing a hook action (since dpkg 1.15.4). Contains the current dpkg action.DPKG_RUNNING_VERSIONDefined by dpkg on the maintainer script environment to the version of the currently running dpkg instance (since dpkg1.14.17).DPKG_MAINTSCRIPT_PACKAGEDefined by dpkg on the maintainer script environment to the (non-arch-qualified) package name being handled (since dpkg1.14.17).DPKG_MAINTSCRIPT_PACKAGE_REFCOUNTDefined by dpkg on the maintainer script environment to the package reference count, i.e. the number of package instances witha state greater than not-installed (since dpkg 1.17.2).DPKG_MAINTSCRIPT_ARCHDefined by dpkg on the maintainer script environment to the architecture the package got built for (since dpkg 1.15.4).DPKG_MAINTSCRIPT_NAMEDefined by dpkg on the maintainer script environment to the name of the script running, one of preinst, postinst, prerm orpostrm (since dpkg 1.15.7).DPKG_MAINTSCRIPT_DEBUGDefined by dpkg on the maintainer script environment to a value (‘0’ or ‘1’) noting whether debugging has been requested (withthe --debug option) for the maintainer scripts (since dpkg 1.18.4).FILES/etc/dpkg/dpkg.cfg.d/[0-9a-zA-Z_-]*Configuration fragment files (since dpkg 1.15.4)./etc/dpkg/dpkg.cfgConfiguration file with default options./var/log/dpkg.logDefault log file (see /etc/dpkg/dpkg.cfg and option --log).The other files listed below are in their default directories, see option --admindir to see how to change locations of these files./var/lib/dpkg/availableList of available packages./var/lib/dpkg/statusStatuses of available packages. This file contains information about whether a package is marked for removing or not, whetherit is installed or not, etc. See section INFORMATION ABOUT PACKAGES for more info.The status file is backed up daily in /var/backups. It can be useful if it's lost or corrupted due to filesystems troubles.The format and contents of a binary package are described in deb(5).BUGS
dpkg --triggers ...