Home > Package & System Management > dpkg

dpkg: Debian Package Management

dpkg is a low-level package management system for installing, removing, and managing Debian (.deb) packages. It serves as the foundation for higher-level tools like APT, but it does not automatically handle package dependencies, so caution is advised.

Overview

dpkg is a command-line tool that directly handles Debian packages (.deb files). It provides functionalities for installing, removing, querying information about, and checking the status of packages. It acts as the core backend for higher-level package management tools like APT.

Key Features

  • Install and remove local .deb files
  • Query installed package list and status
  • Inspect package file contents and information
  • Manually manage package dependencies (unlike APT, it does not resolve them automatically)

Main Options

Package Management

Information Query

Generated command:

Try combining the commands.

Description:

`dpkg` Executes the command.

Combine the above options to virtually execute commands with AI.

Usage Examples

Install a Local .deb File

sudo dpkg -i /path/to/your_package.deb

Installs a downloaded .deb package file. Dependency issues may arise.

Remove an Installed Package

sudo dpkg -r package_name

Removes the specified package, but leaves its configuration files.

Purge an Installed Package

sudo dpkg -P package_name

Completely removes the specified package and all its associated configuration files.

List All Installed Packages

dpkg -l

Displays a list of all Debian packages installed on the system.

Check Status of a Specific Package

dpkg -s package_name

Verifies the current installation status and detailed information for a specified package.

Inspect Contents of a .deb File

dpkg -c /path/to/your_package.deb

Before installing, check which files are included within a .deb file.

Search for the Package Owning a File

dpkg -S /usr/bin/ls

Find out which Debian package installed a specific file.

Tips & Caveats

dpkg is a low-level tool, and you may need to resolve dependency issues manually. Generally, using APT is recommended.

Dependency Issues

dpkg does not automatically resolve package dependencies. If you try to install a package with `dpkg -i` and a required dependency is missing, the installation may fail. In such cases, you can use the command `sudo apt install -f` to resolve missing dependencies.

  • Resolve Dependencies: sudo apt install -f

Recommended to Use APT

In most situations, using the `apt` command is more convenient and safer than using `dpkg` directly. `apt` is a higher-level tool that automates complex tasks like dependency resolution and repository management.

  • Install .deb using APT: sudo apt install ./your_package.deb

Package Status Codes

In the output of `dpkg -l`, the first column indicates the status of the package. For example, `ii` means 'Installed', `rc` means 'Removed' with 'Config-files' remaining, and `pn` means 'Purged' with 'No config-files'.


Same category commands