dpkg(1)
dpkg is the low-level package manager for Debian and Ubuntu systems, handling installation, removal, and management of .deb files.
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
| Flag | What it does |
|---|---|
-i, --install | Install a package from a .deb file |
-r, --remove | Remove a package (keeps config files) |
-P, --purge | Remove a package and delete all config files |
-l, --list | List all installed packages |
-L, --listfiles | Show all files installed by a package |
-s, --status | Show detailed status of a package |
-S, --search | Find which package owns a file |
-C, --audit | Check for broken package dependencies |
--configure | Configure an installed package |
--purge | Remove package completely including configs |
-c, --contents | List files in a .deb package file |
--force-all | Force actions even if dependencies unmet (dangerous) |
Examples
Install a .deb file directly
dpkg -i ./package.debList all installed packages and filter for nginx
dpkg -l | grep nginxShow all files installed by the nginx package
dpkg -L nginxFind which package owns the /usr/bin/curl file
dpkg -S /usr/bin/curlRemove postgresql package but keep its config files
dpkg -r postgresqlCompletely remove postgresql including all config files
dpkg -P postgresqlShow detailed status and version info for the bash package
dpkg -s bashList all files inside a .deb file without installing
dpkg -c ./package.deb