Dpkg Command Guide
Understanding the Dpkg Command
The dpkg command is the low-level package manager for
Debian-based Linux distributions. It handles the installation,
removal, and management of individual Debian package files
(.deb). While higher-level tools like
apt provide more user-friendly dependency resolution
and repository management, dpkg is fundamental for
direct package manipulation.
Key Dpkg Operations
Here are some essential dpkg commands for managing your
Debian system:
Querying Package File Ownership
This command is invaluable for determining which installed package provides a specific file. It helps in understanding system file origins and troubleshooting.
# dpkg -S /path/to/file
# Example: Find which package owns the 'awk' executable
dpkg -S /usr/bin/awk
Installing a Debian Package
Use the -i flag to install a local
.deb file. Note that dpkg does not
automatically resolve dependencies; you might need to use
apt afterwards if dependencies are missing.
# dpkg -i /path/to/your_package.deb
# Example: Install a downloaded package file
dpkg -i my-custom-app_1.0.0_amd64.deb
Listing Installed Packages
To view a list of all installed packages and their current status,
use the --get-selections or -l options.
# List packages and their desired state (install, hold, deinstall, purge)
dpkg --get-selections
# List installed packages with detailed information (status, version, architecture)
dpkg -l