dpkg is a low-level package management command-line tool used in Debian-based systems to install, configure, and remove software packages. This cheat sheet covers essential dpkg commands for managing packages.
Introduction:
dpkg directly interacts with the Debian package system, providing low-level package management capabilities. It is the underlying tool for package management on Debian-based systems.
Basic Commands:
Command
Description
sudo dpkg -i [package.deb]
Install a .deb package file.
sudo dpkg -r [package]
Remove (uninstall) a package.
sudo dpkg -P [package]
Purge a package, removing its configuration files.
sudo dpkg -L [package]
List files installed by a package.
sudo dpkg -l
List all installed packages.
sudo dpkg -s [package]
Display information about a package.
Querying and Searching:
Command
Description
dpkg-query -l
List all installed packages.
dpkg-query -L [package]
List files installed by a package.
dpkg-query -S [file]
Find the package providing a specific file.
`dpkg -l
grep [keyword]`
Updating and Clearing:
Command
Description
sudo dpkg --configure -a
Configure all unpacked but unconfigured packages.
sudo dpkg-reconfigure [package]
Reconfigure a package.
sudo dpkg --clear-selections
Clear the package selections.
Information and Troubleshooting:
Command
Description
dpkg --get-selections
List all installed packages and their status.
dpkg-reconfigure [package]
Reconfigure a package.
sudo dpkg --audit
Check for broken dependencies and missing packages.
Miscellaneous:
Command
Description
sudo dpkg --add-architecture [architecture]
Add a new architecture (e.g., i386 for 32-bit) to the system.
sudo dpkg --remove-architecture [architecture]
Remove an architecture from the system.
sudo dpkg -I [package.deb]
Display information about a .deb package file.
dpkg --help
Display help and usage information for dpkg.
Conclusion
dpkg is a fundamental tool for managing packages on Debian-based systems. This cheat sheet covers essential commands for installing, removing, querying, and troubleshooting packages using dpkg. Whether you are a system administrator or a Debian user, these commands will help you efficiently manage software packages on your system.