dpkg
Install, remove, and manage Debian packages
TLDR
Install a package
Remove a package
List installed packages
List a package's contents
List contents of a local package file
Find out which package owns a file
Purge an installed or already removed package, including configuration
SYNOPSIS
dpkg [option ...] command [package ...]
PARAMETERS
-i, --install .deb file
Install the package specified by the .deb file.
-r, --remove package_name
Remove the package. Configuration files are left intact.
-P, --purge package_name
Remove the package and its configuration files.
-l, --list [package_name_pattern]
List packages matching the specified pattern (or all if none given).
-s, --status package_name
Display detailed information about the specified package.
-c, --contents .deb file
List the contents of the specified .deb archive file.
--configure package_name
Reconfigure an unpacked package.
--unpack .deb file
Unpack a .deb file without configuring it.
--help
Display help information.
--version
Display the version of dpkg.
DESCRIPTION
The dpkg command is the primary tool for installing, building, removing, and managing .deb packages on Debian-based Linux distributions, such as Ubuntu, Mint, and Debian itself. It is a low-level tool, meaning it primarily handles package files and their metadata, but does not directly manage dependencies. Dependency resolution is typically handled by front-end tools like apt or aptitude. dpkg can be used to install packages from local .deb files, query package information, list files within a package, and configure installed packages.
It's important to remember that dpkg focuses solely on the packages themselves. When installing a package, if dpkg encounters unmet dependencies, it will install the package but indicate that dependencies are broken. The user must then use a front-end tool like apt to resolve these dependencies to ensure proper package functionality.
CAVEATS
dpkg does not handle dependency resolution. Use apt or aptitude for that.
PACKAGE STATES
Packages can be in various states: installed, unpacked, half-installed, etc. Use dpkg -s to check a package's current state. States like half-installed usually indicate a problem that needs resolution using apt or manual intervention.
UNDERSTANDING OUTPUT OF DPKG -L
The output of dpkg -l is organized into columns: the first indicates the desired action(u for unknown, i for install, r for remove, p for purge), the second indicates the current state of the package (i for installed, c for config-files, u for unpacked, etc.), and the third indicates the error flags if any (e.g., rc for removal failed, config-files remain).
HISTORY
dpkg was created as part of the Debian project in 1993 by Ian Jackson, to replace the older system based on installpkg. It has been continuously developed and improved since then, becoming a fundamental part of Debian and its derivatives. Its primary role remains consistent: managing individual package files and maintaining the system's package database.
SEE ALSO
apt(8), aptitude(8), dpkg-deb(1), dpkg-query(1)