# info > Dpkg

---
type: CommandReference
command: dpkg
mode: man
section: 1
source: man-pages
---

## Quick Reference
- `dpkg -i package.deb` — Install a package
- `dpkg -r package` — Remove a package (keep config files)
- `dpkg -P package` — Purge a package (remove all)
- `dpkg -l '*pattern*'` — List installed packages matching pattern
- `dpkg -s package` — Show package status
- `dpkg -L package` — List files installed by a package
- `dpkg --get-selections` — Output package selection states
- `dpkg --set-selections < file` — Set package selections from file

## Name
dpkg - package manager for Debian

## Synopsis
shell
dpkg [option...] action
## Options

### Core Actions
- `-i, --install package-file...` — Install the package
- `--unpack package-file...` — Unpack but do not configure
- `--configure package...|-a|--pending` — Configure unpacked packages
- `--triggers-only package...|-a|--pending` — Process only triggers
- `-r, --remove package...|-a|--pending` — Remove an installed package
- `-P, --purge package...|-a|--pending` — Purge (remove everything, including conffiles)
- `-V, --verify [package-name...]` — Verify package integrity (md5sum)
- `-C, --audit [package-name...]` — Database sanity checks
- `--update-avail [Packages-file]` — Replace available info
- `--merge-avail [Packages-file]` — Merge available info
- `-A, --record-avail package-file...` — Add packages to available list
- `--forget-old-unavail` — No-op (automatic now)
- `--clear-avail` — Erase available info
- `--get-selections [package-name-pattern...]` — Print selection states
- `--set-selections` — Read selection states from stdin
- `--clear-selections` — Set all non-essential packages to deinstall
- `--yet-to-unpack` — Show packages selected but not installed
- `--predep-package` — Print a pre-dependency target
- `--add-architecture architecture` — Add architecture to allowed list
- `--remove-architecture architecture` — Remove architecture from allowed list
- `--print-architecture` — Print native architecture
- `--print-foreign-architectures` — Print extra architectures
- `--assert-help` — Help about `--assert-*` options
- `--assert-feature` — Check feature support
- `--validate-thing string` — Validate syntax of a thing
- `--compare-versions ver1 op ver2` — Compare version numbers

### dpkg-deb Actions (delegated)
- `-b, --build` — Build a .deb
- `-c, --contents` — List contents of a .deb
- `-e, --control` — Extract control info
- `-x, --extract` — Extract files
- `-X, --vextract` — Extract and list filenames
- `-f, --field` — Show control fields
- `--ctrl-tarfile` — Output control.tar
- `--fsys-tarfile` — Output data.tar
- `-I, --info` — Show package info

### dpkg-query Actions (delegated)
- `-l, --list` — List packages matching pattern
- `-s, --status` — Show package status
- `-L, --listfiles` — List files from package
- `-S, --search` — Search for a filename
- `-p, --print-avail` — Show available info (APT frontends prefer `apt show`)

### Behaviour Modifiers
- `--abort-after=number` — Abort after N errors (default 50)
- `-B, --auto-deconfigure` — Auto-deconfigure dependent packages on removal
- `-D, --debug=octal` — Enable debugging (bitmask)
- `--force-things` — Force dangerous operations (see `--force-help`)
- `--no-force-things, --refuse-things` — Refuse operations
- `--ignore-depends=package,...` — Ignore dependency checks for listed packages
- `--no-act, --dry-run, --simulate` — Simulate, do not modify
- `-R, --recursive` — Recurse into directories for *.deb
- `-G` — Refuse to downgrade (alias for `--refuse-downgrade`)
- `--admindir=dir` — Set administrative directory (default `/var/lib/dpkg`)
- `--instdir=dir` — Set installation directory (default `/`)
- `--root=dir` — Set root (implies `--instdir` and `--admindir`)
- `-O, --selected-only` — Only process selected packages
- `-E, --skip-same-version` — Skip if same version installed
- `--pre-invoke=command` — Hook before dpkg actions
- `--post-invoke=command` — Hook after dpkg actions
- `--path-exclude=glob-pattern` — Exclude paths during install
- `--path-include=glob-pattern` — Re-include previously excluded paths
- `--verify-format format-name` — Output format for `--verify` (only `rpm`)
- `--status-fd n` — Write machine-readable status to file descriptor
- `--status-logger=command` — Pipe machine-readable status to a command
- `--log=filename` — Log to specified file (default `/var/log/dpkg.log`)
- `--robot` — Machine-readable output (for `--version`)
- `--no-pager` — Disable pager
- `--no-debsig` — Do not verify signatures
- `--no-triggers` — Do not run triggers (still record activations)
- `--triggers` — Cancel `--no-triggers`

## Examples

List installed packages matching `*vi*`:
shell
dpkg -l '*vi*'
Show available info for two packages:
shell
dpkg --print-avail elvis vim | less
Remove the `elvis` package:
shell
dpkg -r elvis
Install a package from the local archive:
shell
dpkg -i vim_4.5-3.deb
Save package selection states:
shell
dpkg --get-selections > myselections
Transfer selections to another system (after updating available):
shell
dpkg --clear-selections
dpkg --set-selections < myselections
Then use `apt-get dselect-upgrade` to perform the install/remove.

## See Also
[aptitude(8)](https://www.chedong.com/phpMan.php/man/aptitude/8/markdown), [apt(8)](https://www.chedong.com/phpMan.php/man/apt/8/markdown), [dselect(1)](https://www.chedong.com/phpMan.php/man/dselect/1/markdown), [dpkg-deb(1)](https://www.chedong.com/phpMan.php/man/dpkg-deb/1/markdown), [dpkg-query(1)](https://www.chedong.com/phpMan.php/man/dpkg-query/1/markdown), [deb(5)](https://www.chedong.com/phpMan.php/man/deb/5/markdown), [deb-control(5)](https://www.chedong.com/phpMan.php/man/deb-control/5/markdown), [dpkg.cfg(5)](https://www.chedong.com/phpMan.php/man/dpkg.cfg/5/markdown), [dpkg-reconfigure(8)](https://www.chedong.com/phpMan.php/man/dpkg-reconfigure/8/markdown)

## Exit Codes
- `0` — Success, or check/assertion returned true
- `1` — Check/assertion returned false
- `2` — Fatal error (invalid usage, database access, memory, etc.)