dpkg
(Debian Package) is the low-level package management tool used in Debian-based systems, including Ubuntu and its derivatives. It allows users to install, remove, and manage .deb
packages. Here’s a brief overview of its key functionalities:
dpkg
CommandsInstall a Package
sudo dpkg -i package.deb
This command installs a .deb
package.
Remove a Package
sudo dpkg -r package_name
This command removes an installed package, but leaves configuration files intact.
Purge a Package
sudo dpkg --purge package_name
This command removes a package and its configuration files.
List Installed Packages
dpkg -l
This lists all installed packages on the system.
Check Package Status
dpkg -s package_name
This displays detailed information about a specific package, including its status.
List Files in a Package
dpkg -L package_name
This shows all files installed by a specific package.
Find a Package That Owns a File
dpkg -S /path/to/file
This command helps find which package a specific file belongs to.
While dpkg
handles individual package files, it does not automatically manage dependencies. For this purpose, tools like apt
(Advanced Package Tool) are commonly used. apt
can resolve dependencies and manage package installations more seamlessly:
Update Package Lists
sudo apt update
Install a Package with Dependencies
sudo apt install package_name
Remove a Package with Dependencies
sudo apt remove package_name
Installing a Package
sudo dpkg -i mypackage.deb
If there are missing dependencies, you can fix them by running:
sudo apt install -f
Removing a Package
sudo dpkg -r mypackage
Listing All Packages
dpkg -l | less
dpkg
is a powerful tool for managing packages in Debian-based systems. For most users, it’s recommended to use apt
for package management due to its ability to handle dependencies automatically. However, dpkg
remains useful for direct manipulation of .deb
files and understanding installed packages.