Linux dpkg Command: Inspect and Install Local DEB Packages

dpkg handles local .deb packages and the installed package database in Debian-based systems. The higher-level tool that looks for dependencies in repositories and downloads them is apt.

dpkg -i installs a local DEB file but does not automatically fetch and resolve required dependency packages from the repository. You can check the status of installed packages with dpkg -s and the list of files with dpkg -L. If you need to install a local file along with its dependencies, consider using your distribution's apt install./file.deb first.

Basic syntax

dpkg [options] action [package or file]

The implemented options may vary depending on the distribution. Check the current system's description with man dpkg.

Examples

Check Installation Status

Check whether it is installed, and view the version and description.

dpkg -s bash

Check Files Belonging to a Package

View the list of files provided by the installed package.

dpkg -L bash

Local DEB Installation

Check the source, version, and dependencies of the file and install it.

sudo dpkg -i ./example.deb

Distinguishing Installation Status and Repository Management

dpkg -s shows the status recorded in the local package database. The following is an example on a Debian-based system with bash installed.

dpkg -s bash

Part of the output format:

Package: bash
Status: install ok installed
Version: ...

install ok installed means the installation status is normal. dpkg -i file.deb installs a local DEB file but is not meant to automatically resolve dependencies from the repository. If dependency issues occur, check apt's recovery and dependency resolution procedures rather than blindly reinstalling the file.

Main Options and Format

Options/Format Description
-i file.deb Installs a local DEB package.
-s package Displays the status of the installed package.
-L package Displays the list of files installed by the package.
-S path Finds the package that owns the path.
-r / -P package Removes a package, or removes it along with its configuration files.

Precautions when using

Do not install untrusted DEB files. The package installation script may run with administrative privileges. If dpkg -i shows dependency errors, do not blindly use the force option; check the package source and required dependencies. -P removes even configuration files, so back them up if recovery is needed.

Frequently Asked Questions

dpkg -i vs apt install./file.deb?

dpkg handles local files directly and does not automatically download repository dependencies. apt resolves dependencies from repositories whenever possible.

Official Documentation

For the exact behavior of options and differences by implementation, refer to the official dpkg documentation.