Skip to main content

dpkg Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for installing, removing, querying, and inspecting Debian packages with dpkg

dpkg is the low-level package manager used by Debian, Ubuntu, and related distributions. This cheatsheet covers common dpkg commands for local .deb files, installed package queries, package selections, and repair tasks.

Install and Remove

Work with installed packages and local .deb files.

CommandDescription
sudo dpkg -i package.debInstall a local .deb file
sudo dpkg -i *.debInstall multiple .deb files
sudo dpkg -r packageRemove package, keep config
sudo dpkg -P packagePurge package and config
sudo dpkg --unpack package.debUnpack without configuring

Query Installed Packages

List packages and inspect installed package metadata.

CommandDescription
dpkg -lList installed packages
dpkg -l 'nginx*'Filter packages by pattern
dpkg -s packageShow package status
dpkg --status packageSame as dpkg -s
dpkg-query -W packageShow package and version

Package Files

Find installed files and file ownership.

CommandDescription
dpkg -L packageList files installed by package
dpkg -S /path/to/fileFind package owning a file
dpkg -S '*/bin/curl'Search ownership by pattern
dpkg -L package | lessBrowse long file lists
dpkg -V packageVerify installed package files

Inspect deb Files

Read package archives before installing them.

CommandDescription
dpkg --info package.debShow .deb metadata
dpkg -I package.debSame as dpkg --info
dpkg --contents package.debList files in .deb
dpkg -c package.debSame as dpkg --contents
dpkg-deb -f package.deb VersionPrint package version field

Extract deb Files

Unpack archive contents without installing.

CommandDescription
dpkg -x package.deb /tmp/extractExtract package files
dpkg -X package.deb /tmp/extractExtract with details
dpkg -e package.deb /tmp/controlExtract control files
dpkg-deb --ctrl-tarfile package.debPrint control tar archive
dpkg-deb --fsys-tarfile package.debPrint filesystem tar archive

Package Selections

Export and restore package selection states.

CommandDescription
dpkg --get-selectionsPrint package selections
dpkg --get-selections > packages.txtSave selections
sudo dpkg --set-selections < packages.txtRestore selections
dpkg --get-selections 'nginx*'Filter selections
sudo apt-get dselect-upgradeApply restored selections

Repair and Configure

Resume interrupted installs and fix package state.

CommandDescription
sudo dpkg --configure -aConfigure pending packages
sudo dpkg --configure packageConfigure one package
sudo dpkg -CAudit broken packages
sudo apt install -fFix missing dependencies
sudo dpkg-reconfigure packageRe-run package setup

Use these references for package management workflows.

GuideDescription
dpkg Command in LinuxFull dpkg tutorial with examples
Install deb Files on UbuntuInstall local .deb files with apt and dpkg
apt CheatsheetHigher-level package management commands