The dpkg command is a core tool for managing .deb packages in Debian-based Linux distributions, including Ubuntu and Linux Mint. While tools like apt and synaptic offer more automation and user-friendliness, dpkg gives you precise, low-level control over package installation, removal, and inspection.Whether you’re a Linux beginner or a system administrator, understanding how to use dpkg can help you debug issues, manually install packages, and manage software outside standard repositories.
dpkg stands for Debian Package and is a command-line tool used to install, configure, remove, and inspect .deb packages. Unlike apt, it does not automatically resolve dependencies, making it more direct but potentially more error-prone if used carelessly.
sudo dpkg -i package-name.deb
This command installs a .deb
file. If dependencies are missing, run:
sudo apt-get install -f
This will fix broken dependencies by downloading missing packages.
Remove a package but keep configuration files:
sudo dpkg -r package-name
Remove a package and its config files:
sudo dpkg -P package-name
dpkg -l
This lists all installed packages in a tabular format, including:
This screenshot shows how dpkg -l outputs the full list of packages currently installed on the system. You can scroll or filter this list using grep:
dpkg -l | grep apache
View package metadata without installing:
dpkg -I package-name.deb
List files contained in the .deb:
dpkg -c package-name.deb
dpkg
dpkg works together with various companion tools:
These are useful for packaging, debugging, and low-level package management.
The dpkg command is an essential tool in the Debian package ecosystem. While it’s not beginner-friendly compared to apt, it’s powerful and flexible, especially when you need to:
Understanding dpkg empowers you to take full control of your Linux environment.