Search notes:

dpkg

dpkg is the package manager for Debian and thus used to install, build, remove and manage Debian packages.
dpkg is a command line tool, a (more user-friendly?) alternative is aptitude.

Usage

dpkg [<option>...] <command>

Commands

long form argument
-i --install <.deb file>… -R|--recursive <directory>…
--unpack <.deb file>>… -R|--recursive <directory>…
-A --record-avail <.deb file name>… -R|--recursive <directory>…
--configure <package>… -a|--pending
--triggers-only <package>… -a|--pending
-r --remove <package>… -a|--pending
-P --purge <package>… -a|--pending
-V --verify [<package>…] Verify the integrity of package(s).
--get-selections [<pattern>…] Get list of selections to stdout.
--set-selections Set package selections from stdin.
--clear-selections Deselect every non-essential package.
--update-avail [<Packages-file>] Replace available packages info.
--merge-avail [<Packages-file>] Merge with info from file.
--clear-avail Erase existing available info.
--forget-old-unavail Forget uninstalled unavailable pkgs.
-s --status [<package>…] Display package status details. Compare with dpkg-query -s.
-p --print-avail [<package>…] Display available version details. Similar to apt-cache show
-L --listfiles <package>… List files 'owned' by package(s).
-l --list [<pattern>…] List packages concisely. Compare with dpkg-query -W … and apt list …
-S --search <pattern>… Find package(s) owning file(s).
-C --audit [<package>…] Check for broken package(s).
--yet-to-unpack Print packages selected for installation.
--predep-package Print pre-dependencies to unpack.
--add-architecture <arch> Add <arch> to the list of architectures.
--remove-architecture <arch> Remove <arch> from the list of architectures.
--print-architecture Print dpkg architecture.
--print-foreign-architectures Print allowed foreign architectures.
--assert-<feature> Assert support for the specified feature. <feature> is one of support-predepends, working-epoch, long-filenames, multi-conrep, multi-arch, versioned-provides, protected-field.
--validate-<thing> <string> Validate a <thing>'s <string>. <thing> is one of pkgname, archname, trigname, version.
--compare-versions <a> <op> <b> Compare version numbers. <op> is one of lt, le, eq, ne, ge, gt (treat empty version as earlier than any version) / lt-nl, le-nl, ge-nl, gt-nl (treat empty version as later than any version) / <, <<, <=, =, >=, >>, > (only for compatibility with control file syntax).
--force-help Show help on forcing.
-Dh --debug=help Show help on debugging.
-? --help Show this help message.
--version Show the version.

Options

--admindir=<directory> Use <directory> instead of /var/lib/dpkg.
--root=<directory> Install on a different root directory.
--instdir=<directory> Change installation dir without changing admin dir.
--pre-invoke=<command> Set a pre-invoke hook.
--post-invoke=<command> Set a post-invoke hook.
--path-exclude=<pattern> Do not install paths which match a shell pattern.
--path-include=<pattern> Re-include a pattern after a previous exclusion.
-O --selected-only Skip packages not selected for install/upgrade.
-E --skip-same-version Skip packages whose same version is installed.
-G --refuse-downgrade Skip packages with earlier version than installed.
-B --auto-deconfigure Install even if it would break some other package.
--[no-]triggers Skip or force consequential trigger processing.
--verify-format=<format> Verify output format (supported: 'rpm').
--no-pager Disables the use of any pager.
--no-debsig Do not try to verify package signatures.
--no-act|--dry-run|--simulate Just say what we would do but don't do it.
-D --debug=<octal> Enable debugging (see -Dhelp or --debug=help).
--status-fd <n> Send status change updates to file descriptor <n>.
--status-logger=<command> Send status change updates to <command>'s stdin.
--log=<filename> Log status changes and actions to <filename> (See also /var/log/dpkg.log).
--ignore-depends=<package>[,…] Ignore dependencies involving <package>.
--force-<thing>[,…] Override problems (see --force-help).
--no-force-<thing>[,…] Stop when problems encountered.
--refuse-<thing>[,…] Ditto.
--abort-after <n> Abort after encountering <n> errors.
--robot Use machine-readable output on some commands.

Options on archives

-b --build
-c --contents Displays a .deb file's content. Compare with -I.
-e --control
-I --info Compare with -c
-f --field
-x --extract
-X --vextract
--ctrl-tarfile
--fsys-tarfile
Compare with
$ dpkg-deb --help

-I / --info

$ dpkg -I ./apt-file_3.3_all.deb
 new Debian package, version 2.0.
 size 39104 bytes: control archive=1292 bytes.
      36 bytes,     1 lines      conffiles
     530 bytes,    12 lines      control
     812 bytes,    11 lines      md5sums
     367 bytes,    18 lines   *  postinst             #!/bin/sh
     176 bytes,    10 lines   *  postrm               #!/bin/sh
 Package: apt-file
 Version: 3.3
 Architecture: all
 Maintainer: APT Development Team <deity@lists.debian.org>
 Installed-Size: 89
 Depends: perl:any, apt, libapt-pkg-perl, libregexp-assemble-perl
 Section: admin
 Priority: optional
 Description: search for files within Debian packages (command-line interface)
  apt-file is a command line tool for searching files contained in packages
  for the APT packaging system. You can search in which package a file is
  included or list the contents of a package without installing or fetching it.
Compare with -c

-c / --contents

$ dpkg -c ./apt-file_3.3_all.deb
drwxr-xr-x root/root         0 2022-09-10 12:35 ./
drwxr-xr-x root/root         0 2022-09-10 12:35 ./etc/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./etc/apt/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./etc/apt/apt.conf.d/
-rw-r--r-- root/root      2164 2022-09-10 12:35 ./etc/apt/apt.conf.d/50apt-file.conf
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/bin/
-rwxr-xr-x root/root     31783 2022-09-10 12:35 ./usr/bin/apt-file
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/apt-file/
-rwxr-xr-x root/root       187 2022-09-10 12:35 ./usr/share/apt-file/is-cache-empty
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/bash-completion/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/bash-completion/completions/
-rw-r--r-- root/root      1344 2020-03-19 22:17 ./usr/share/bash-completion/completions/apt-file
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/doc/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/doc/apt-file/
-rw-r--r-- root/root       762 2022-09-10 12:29 ./usr/share/doc/apt-file/NEWS.Debian.gz
-rw-r--r-- root/root      3631 2020-03-19 22:17 ./usr/share/doc/apt-file/README.md.gz
-rw-r--r-- root/root     13744 2022-09-10 12:35 ./usr/share/doc/apt-file/changelog.gz
-rw-r--r-- root/root       464 2014-06-19 17:20 ./usr/share/doc/apt-file/copyright
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/doc/apt-file/examples/
-rw-r--r-- root/root       422 2020-03-19 22:17 ./usr/share/doc/apt-file/examples/60disable-contents-fetching.conf
-rwxr-xr-x root/root      1973 2020-03-19 22:17 ./usr/share/doc/apt-file/examples/apt-file-2-update.sh
-rw-r--r-- root/root      1381 2020-03-19 22:17 ./usr/share/doc/apt-file/examples/apt-file.conf
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/man/
drwxr-xr-x root/root         0 2022-09-10 12:35 ./usr/share/man/man1/
-rw-r--r-- root/root      7130 2022-09-10 12:35 ./usr/share/man/man1/apt-file.1.gz
Compare with -I

-L

dpkg -L lists files (and directories) that are «owned» by an (installed) package.
The following command lists the files which are installed by the openssh-client package:
$ dpkg -L openssh-client
In order to find which packages owns a file that is not yet installed, apt-file or the Ubuntu package search can be used:
$ sudo apt-get install apt-file
$ sudo apt-file update
$ apt-file find /usr/bin/scp
$ apt-file find -x '\blspci$'
A (faster?) alternative to dpgk -L (and dpgk -S) queries is dlocate.

-S

dpkg -S lists the package that «owns» a file.
The following command shows that the package openssh-client owns the file /usr/bin/scp:
$ dpkg -S /usr/bin/scp
openssh-client: /usr/bin/scp

dpkg-* programs

dpkg-architecture set and determine the architecture for package building
dpkg-buildflags returns build flags to use during package build
dpkg-buildpackage build binary or source packages from sources
dpkg-checkbuilddeps check build dependencies and conflicts
dpkg-deb Debian package archive (.deb) manipulation tool. (dpkg can also be used as a frontend for dpkg-query)
dpkg-distaddfile add entries to debian/files
dpkg-divert override a package's version of a file
dpkg-genbuildinfo generate Debian .buildinfo files
dpkg-genchanges generate Debian .changes files
dpkg-gencontrol generate Debian control files
dpkg-gensymbols generate symbols files (shared library dependency information)
dpkg-maintscript-helper works around known dpkg limitations in maintainer scripts
dpkg-mergechangelogs 3-way merge of debian/changelog files
dpkg-name rename Debian packages to full package names
dpkg-parsechangelog parse Debian changelog files
dpkg-query a tool to query the dpkg database. (dpkg can also be used as a frontend for dpkg-query)
dpkg-realpath print the resolved pathname with DPKG_ROOT support
dpkg-scanpackages create Packages index files
dpkg-scansources create Sources index files
dpkg-shlibdeps generate shared library substvar dependencies
dpkg-source Debian source package (.dsc) manipulation tool
dpkg-split Debian package archive split/join tool
dpkg-statoverride override ownership and mode of files
dpkg-trigger a package trigger utility
dpkg-vendor queries information about distribution vendors

TODO

APT is a high level user friendly utility to operate with dpkg.
sudo dpkg-reconfigure tzdata

See also

/etc/dpkg/dpkg.cfg is the configuration file for dpkg.
/var/lib/dpkg/available contains a list of available packages.
The status of these (all of them?) packages is listed in /var/lib/dpkg/status.
Because dpkg is essential for the proper working of Debian, it is assigned the required package priority.
The default log file is /var/log/dpkg.log.
/var/lib/dpkg, /var/lib/dpkg/lock
The .deb file format.
package manager

Index