🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

dpkg Command

Intermediate Package Management man(1)

Debian package manager for .deb files

👁 10 views 📅 Updated: Mar 15, 2026
SYNTAX
dpkg [OPTION]... ACTION [PACKAGE]

What Does dpkg Do?

dpkg is the low-level Debian package manager that installs, removes, and inspects .deb package files. While apt handles dependencies automatically, dpkg works directly with individual .deb files.

dpkg is used when you download a .deb file directly (from a website or custom build) and need to install it manually. It does not resolve dependencies — you must install dependencies separately or use apt install -f after.

dpkg is also useful for querying installed packages, listing package contents, and checking package status.

Options & Flags

OptionDescriptionExample
-i Install a .deb package sudo dpkg -i package.deb
-r Remove a package sudo dpkg -r package_name
-P Purge (remove with config) sudo dpkg -P package_name
-l List installed packages dpkg -l | grep nginx
-L List files installed by package dpkg -L nginx
-S Find which package owns a file dpkg -S /usr/bin/nginx
-s Show package status dpkg -s nginx
--configure -a Fix interrupted installations sudo dpkg --configure -a

Practical Examples

#1 Install .deb file

Installs a downloaded .deb package.
$ sudo dpkg -i google-chrome-stable.deb

#2 Fix dependencies

Installs a .deb, then resolves any missing dependencies.
$ sudo dpkg -i package.deb; sudo apt install -f

#3 List installed packages

Lists all installed packages matching "php".
$ dpkg -l | grep php
Output: ii php8.2 8.2.0-1 amd64 PHP scripting language

#4 Find package for file

Shows which package installed a specific file.
$ dpkg -S /etc/nginx/nginx.conf
Output: nginx-common: /etc/nginx/nginx.conf

#5 List package files

Shows all files installed by the nginx package.
$ dpkg -L nginx

#6 Fix broken install

Configures any packages that were left in an unconfigured state.
$ sudo dpkg --configure -a

Tips & Best Practices

Install then fix deps: sudo dpkg -i file.deb && sudo apt install -f. The apt install -f resolves missing dependencies automatically.
dpkg -S for file ownership: dpkg -S /path/to/file tells you which package installed that file — very useful for troubleshooting.
No dependency resolution: dpkg does not install dependencies. Use apt install package to get dependencies resolved automatically.

Frequently Asked Questions

How do I install a .deb file?
sudo dpkg -i file.deb. If dependencies are missing, run sudo apt install -f to resolve them.
How do I find which package a file belongs to?
dpkg -S /path/to/file shows the package that installed that file.
What is the difference between dpkg and apt?
dpkg manages individual .deb files without dependency resolution. apt handles dependencies automatically from repositories.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →