$linuxjunkies
>

dpkg(1)

dpkg is the low-level package manager for Debian and Ubuntu systems, handling installation, removal, and management of .deb files.

UbuntuDebianFedoraArch

Synopsis

dpkg [OPTION]... ACTION [FILE]...

Description

dpkg is the core package management tool for Debian-based systems. It installs, removes, configures, and manages individual .deb packages. Unlike apt or apt-get (which handle dependencies automatically), dpkg works directly with package files and the local package database.

dpkg maintains a database of installed packages in /var/lib/dpkg and tracks their files, versions, and configuration. It can install packages, list what's installed, check package contents, and manage dependencies (though it won't automatically fetch missing dependencies—that's apt's job).

Most users interact with dpkg indirectly through apt, but dpkg is essential for scripting, troubleshooting broken package states, and directly managing .deb files.

Common options

FlagWhat it does
-i, --installInstall a package from a .deb file
-r, --removeRemove a package (keeps config files)
-P, --purgeRemove a package and delete all config files
-l, --listList all installed packages
-L, --listfilesShow all files installed by a package
-s, --statusShow detailed status of a package
-S, --searchFind which package owns a file
-C, --auditCheck for broken package dependencies
--configureConfigure an installed package
--purgeRemove package completely including configs
-c, --contentsList files in a .deb package file
--force-allForce actions even if dependencies unmet (dangerous)

Examples

Install a .deb file directly

dpkg -i ./package.deb

List all installed packages and filter for nginx

dpkg -l | grep nginx

Show all files installed by the nginx package

dpkg -L nginx

Find which package owns the /usr/bin/curl file

dpkg -S /usr/bin/curl

Remove postgresql package but keep its config files

dpkg -r postgresql

Completely remove postgresql including all config files

dpkg -P postgresql

Show detailed status and version info for the bash package

dpkg -s bash

List all files inside a .deb file without installing

dpkg -c ./package.deb

Related commands