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.

What is the dpkg command?

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.

More in This Category
Linux command Command: Run Commands While Bypassing Aliases and Functions

Linux command Command: Run Commands While Bypassing Aliases and Functions

Learn how to use the Linux command command to check command availability and bypass shell aliases or functions, with essential options, practical examples, output interpretation, and common troubleshooting tips.

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

Trace the history of Linux from Unix and the GNU Project through the first Linux kernel, distributions, enterprise adoption, cloud computing, containers, and modern infrastructure.

Linux tee Command: Display and Save Pipeline Output

Linux tee Command: Display and Save Pipeline Output

Learn how to display and Save Pipeline Output with the Linux tee command, including practical examples, key options, and important precautions.

Linux cmp Command: Compare Files Byte by Byte

Linux cmp Command: Compare Files Byte by Byte

Learn how Linux cmp compares two files byte by byte, reports the first mismatch, runs silently in scripts, limits ranges, and differs from diff and checksums.

Linux who Command: List Logged-In Users

Linux who Command: List Logged-In Users

Learn how to list Logged-In Users with the Linux who command, including practical examples, key options, and important precautions.

Linux uptime Command: Check Uptime and Load Averages

Linux uptime Command: Check Uptime and Load Averages

Learn how to use the Linux uptime command to check how long the system has been running and interpret load averages, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux basename Command: Extract the Final Component of a Path

Linux basename Command: Extract the Final Component of a Path

Learn how to use the Linux basename command to remove directory prefixes and optional suffixes from path strings, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux file Command: Identify File Types and Formats

Linux file Command: Identify File Types and Formats

Learn how to use the Linux file command to identify file formats from their contents instead of filename extensions, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux chgrp Command: Change a File's Group

Linux chgrp Command: Change a File's Group

Learn how to change a File's Group with the Linux chgrp command, including practical examples, key options, and important precautions.

Linux man Command: Read Command Manual Pages

Linux man Command: Read Command Manual Pages

Learn how to use the Linux man command to find and read command manuals, sections, options, and related pages, with essential options, practical examples, output interpretation, and common troubleshooting tips.