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 locate Command: Search Indexed File Paths Quickly

Linux locate Command: Search Indexed File Paths Quickly

Learn how Linux locate searches a filename database, how updatedb affects freshness, how to limit and filter matches, and when find is the better tool.

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 sftp Command: Transfer Files Securely over SSH

Linux sftp Command: Transfer Files Securely over SSH

Learn how to use the Linux sftp command to transfer and manage files securely through an SSH connection, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux mv Command: Move and Rename Files and Directories

Linux mv Command: Move and Rename Files and Directories

Learn how to move and rename files or directories with Linux mv, avoid unwanted overwrites, clarify destination paths, and handle cross-filesystem moves.

Linux paste Command: Join Corresponding Lines Side by Side

Linux paste Command: Join Corresponding Lines Side by Side

Learn how to join Corresponding Lines Side by Side with the Linux paste command, including practical examples, key options, and important precautions.

Linux traceroute Command: Trace Routers on the Way to a Host

Linux traceroute Command: Trace Routers on the Way to a Host

Learn how to trace Routers on the Way to a Host with the Linux traceroute command, including practical examples, key options, and important precautions.

Linux mkdir Command: Create Directories and Parent Paths

Linux mkdir Command: Create Directories and Parent Paths

Learn how to create directories with Linux mkdir, build missing parent paths, set permissions, understand umask behavior, and verify results in scripts.

Linux host Command: Look Up DNS Names and Addresses

Linux host Command: Look Up DNS Names and Addresses

Learn how to look Up DNS Names and Addresses with the Linux host command, including practical examples, key options, and important precautions.

Linux cd Command: Change the Current Directory

Linux cd Command: Change the Current Directory

Learn how to use the Linux cd command to move between directories using absolute, relative, home, and previous paths, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Directory Structure Explained: Purpose of Major Directories

Linux Directory Structure Explained: Purpose of Major Directories

Understand the purpose of major Linux directories such as /etc, /var, /usr, /home, /proc, and /sys, and learn where common system files belong.