Dpkg
lastmod 2025-12-08created 2015-12-1632 edits
dpkg is the software at the base of the Debian package management system. The dpkg command is used to install, remove, and provide information about .deb packages.
dpkg itself is a low-level tool; higher-level tools such as APT handle complex package relationships and fetching packages from remote locations. Aptitude, Synaptic, and others are used more than dpkg itself, because they have more ways of dealing with package dependencies and a more user-friendly interface.
Along with the dpkg program, the Debian package "dpkg" installs several other programs that make the packaging system work, such as dpkg-statoverride, dpkg-divert, dpkg-trigger and update-alternatives. dpkg installs programs such as start-stop-daemon and install-info, and install-info is generally kept for backward compatibility. (It is now developed and distributed separately.) The Debian package "dpkg-dev" contains the various tools described below.
Categories
- dh_make
- gdebi
- apt-get
- dpkg
- dpkg:Build - notes on how to build a debian package.
- dpkg-deb - Debian package archive (.deb) manipulation tool - can extract archives, among other things.
- dpkg-reconfigure
- dpkg-shlibdeps
- debconf
- Debian package repository
dpkg list status
The first column of the dpkg -list corresponds to the status of a package. How to interpret this status.
Status of every package is represented by three characters xxx
First character: The possible value for the first character. The first character signifies the desired state, like we (or some user) is marking the package for installation
- u: Unknown (an unknown state)
- i: Install (marked for installation)
- r: Remove (marked for removal)
- p: Purge (marked for purging)
- h: Hold
Second Character: The second character signifies the current state, whether it is installed or not. The possible values are
- n: Not- The package is not installed
- i: Inst – The package is successfully installed
- c: Cfg-files – Configuration files are present
- u: Unpacked- The package is stilled unpacked
- f: Failed-cfg- Failed to remove configuration files
- h: Half-inst- The package is only partially installed
- W: trig-aWait
- t: Trig-pend
Third Character: This corresponds to the error state. The possible value include
- R: Reinst-required The package must be installed.
How to create package
See debconf.
Example
Examples of using dpkg are summarized below.
-
dpkg -i [.deb파일]: installs the given file. -
dpkg -r [패키지명]: removes the package from the system. (However, files are left behind on removal.) -
dpkg -P [패키지명]: removes both the package and its configuration files. -
dpkg -x [.deb파일] [디랙토리]: extracts the files contained in the file into the specified directory. Note that this command initializes that directory. -
dpkg -l: List packages concisely. -
dpkg -l [패키지명]: package details. Prints the name, version, dependencies, and so on.
-
dpkg --get-selections - Prints the package list.
- For the output states, see #Package selection states.
-
dpkg --get-selections | grep -P '(?<!de)install$' - Prints the list of all installed packages. However, the package architecture is included. (e.g.
mesa-va-drivers:amd64) - For the output states, see #Package selection states.
-
dpkg --get-selections | grep -P '(?<!de)install$' | cut -f1 | awk -F: '{print $1}' | sort | uniq - Prints the list of all installed packages. Only package names are printed, without the architecture.
-
cut -f1- removes the #Package selection states (package state). -
awk -F: '{print $1}'- removes the architecture suffix -
sort | uniq- sorts and prints unique entries.
-
-
dpkg --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.
-
dpkg --search filename-search-pattern...,dpkg -S filename-search-pattern... - Search for a filename from installed packages.
- Given a file path, shows which package installed that file.
Package selection states
Running the dpkg --get-selections command prints output like the following.
linux-modules-extra-5.13.0-48-generic install
linux-modules-extra-5.13.0-51-generic install
linux-modules-extra-5.8.0-43-generic deinstall
linux-modules-extra-5.8.0-59-generic deinstall
linux-modules-extra-5.8.0-63-generic deinstall
linux-sound-base install
mesa-va-drivers:amd64 install
mesa-va-drivers:i386 install
memtest86+ install
mesa-common-dev:amd64 install
mesa-utils install
mesa-va-drivers:amd64 install
mesa-va-drivers:i386 install
metacity-common install
microsoft-edge-stable install
mime-support install
- install
- The package is selected for installation.
- hold
- A package marked to be on hold is kept on the same version, that is, no automatic new installs, upgrades or removals will be performed on them, unless these actions are requested explicitly, or are permitted to be done automatically with the
--force-holdoption.
- deinstall
- A package that has been removed except for its configuration files. 1
- purge
- The package is selected to be purged (i.e. we want to remove everything from system directories, even configuration files).
- unknown
- The package selection is unknown. A package that is also in a not-installed state, and with an ok flag will be forgotten in the next database store.
Linux Package management systems
| APT (Synaptic, Ubuntu Software Center, KPackage, Adept Manager), aptitude, dselect | |
| Others | Pacman, ipkg, opkg, PPM, Upkg, PISI, Conary, Portage, Entropy, slapt-get, slackpkg, netpkg, swaret |
| Front-ends | PackageKit (GNOME Software, Apper), Autopackage, klik, Listaller, Zero Install |
| Related topics | AppData, AppStream, Application Packaging, Package format |
See also
Favorite site
- Wikipedia (en) explanation of Dpkg
- [Recommended] Chapter 4. Required files under the debian directory
- How to create a local APT repository?
- Creating Ubuntu packages
- Ubuntu package management
References
-
Original text: The package is selected for deinstallation (i.e. we want to remove all files, except configuration files). ↩