Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

Linux & Mac & Bash Command Dictionary

  1. Home
  2. Linux & Mac & Bash Command Dictionary
  3. rpm / dpkg (Low-Level Package Management)

rpm / dpkg (Low-Level Package Management)

rpm is a low-level package management tool used on RHEL, AlmaLinux, and CentOS-based Linux distributions, while dpkg serves the same role on Debian and Ubuntu-based systems. Both tools operate beneath higher-level tools such as apt and dnf, and allow you to directly install, remove, query, and verify .rpm or .deb files. They do not resolve dependencies automatically, so if a required dependency is missing, the command will fail with an error. Use these tools when you need to manually manage downloaded package files or inspect the details of installed packages.

Syntax

# ===============================================
#  rpm (RHEL / AlmaLinux / CentOS)
# ===============================================

# -----------------------------------------------
#  Installing and upgrading packages
# -----------------------------------------------

# rpm -ivh {package.rpm}
#   → Installs the specified .rpm file
#   → -i: install  -v: verbose  -h: show progress bar
#   Example: sudo rpm -ivh gojo-satoru-1.0-1.x86_64.rpm

# rpm -Uvh {package.rpm}
#   → Upgrades a package (installs it if not already installed)
#   → -U: upgrade
#   Example: sudo rpm -Uvh gojo-satoru-2.0-1.x86_64.rpm

# rpm -Fvh {package.rpm}
#   → Upgrades a package only if it is already installed
#   → Does nothing if the package is not installed (-F: freshen)

# -----------------------------------------------
#  Removing packages
# -----------------------------------------------

# rpm -e {package-name}
#   → Removes a package (specify the package name, not the file name)
#   Example: sudo rpm -e gojo-satoru

# rpm -e --nodeps {package-name}
#   → Removes a package while skipping dependency checks
#   → Use with caution — this may break other packages that depend on it

# -----------------------------------------------
#  Querying installed packages
# -----------------------------------------------

# rpm -q {package-name}
#   → Checks whether a package is installed
#   Example: rpm -q nginx

# rpm -qa
#   → Lists all installed packages

# rpm -qi {package-name}
#   → Displays detailed information about a package (version, summary, install date, etc.)

# rpm -ql {package-name}
#   → Lists the files included in an installed package

# rpm -qf {file-path}
#   → Shows which package owns the specified file
#   Example: rpm -qf /usr/bin/nginx

# -----------------------------------------------
#  Querying .rpm files (not yet installed)
# -----------------------------------------------

# rpm -qip {package.rpm}
#   → Displays detailed information from a .rpm file (-p: package file)

# rpm -qlp {package.rpm}
#   → Lists the files contained in a .rpm file

# -----------------------------------------------
#  Verifying packages
# -----------------------------------------------

# rpm -V {package-name}
#   → Verifies that the installed files have not been modified
#   → Changed files are flagged (S: size, M: permissions, 5: MD5, etc.)

# rpm -Va
#   → Verifies all installed packages

# rpm --checksig {package.rpm}
#   → Verifies the GPG signature of a .rpm file

# -----------------------------------------------
#  Managing GPG keys
# -----------------------------------------------

# rpm --import {key-file-or-URL}
#   → Imports a GPG public key
#   → Required for verifying the signature of .rpm files
#   Example: sudo rpm --import https://example.com/RPM-GPG-KEY


# ===============================================
#  dpkg (Debian / Ubuntu)
# ===============================================

# -----------------------------------------------
#  Installing and upgrading packages
# -----------------------------------------------

# dpkg -i {package.deb}
#   → Installs or upgrades a .deb file
#   → Fails with an error if required dependencies are missing
#   Example: sudo dpkg -i ryomen-sukuna_1.0_amd64.deb

# dpkg -i --force-overwrite {package.deb}
#   → Installs the package, overwriting any existing files

# -----------------------------------------------
#  Removing packages
# -----------------------------------------------

# dpkg -r {package-name}
#   → Removes a package but keeps its configuration files
#   Example: sudo dpkg -r ryomen-sukuna

# dpkg -P {package-name}
#   → Removes a package along with its configuration files (purge)

# -----------------------------------------------
#  Querying installed packages
# -----------------------------------------------

# dpkg -l
#   → Lists all installed packages

# dpkg -l {pattern}
#   → Lists packages matching the given pattern
#   Example: dpkg -l "nginx*"

# dpkg -s {package-name}
#   → Displays detailed information about a package (status, version, dependencies, etc.)
#   Example: dpkg -s nginx

# dpkg -L {package-name}
#   → Lists the files installed by a package

# dpkg -S {file-path}
#   → Shows which package owns the specified file
#   Example: dpkg -S /usr/sbin/nginx

# -----------------------------------------------
#  Querying .deb files (not yet installed)
# -----------------------------------------------

# dpkg -I {package.deb}
#   → Displays metadata from a .deb file

# dpkg -c {package.deb}
#   → Lists the files contained in a .deb file

# -----------------------------------------------
#  Extracting .deb files
# -----------------------------------------------

# dpkg-deb -x {package.deb} {target-directory}
#   → Extracts the contents of a .deb file into the specified directory

# dpkg-deb -e {package.deb} {control-directory}
#   → Extracts the control information (DEBIAN/) from a .deb file

# -----------------------------------------------
#  Fixing broken dependencies
# -----------------------------------------------

# dpkg --configure -a
#   → Resumes configuration of any packages whose configuration was interrupted

# apt-get install -f
#   → Fixes broken dependencies left by a dpkg operation

Command reference

OperationCommandDescription
rpm (RHEL / AlmaLinux / CentOS)
Installrpm -ivh {package.rpm}Installs a .rpm file with verbose output and a progress bar.
Upgraderpm -Uvh {package.rpm}Upgrades a package. Installs it if not already present.
Removerpm -e {package-name}Removes a package. Specify the package name, not the file name.
Check installationrpm -q {package-name}Checks whether a package is installed.
List all packagesrpm -qaLists all installed packages.
Show detailsrpm -qi {package-name}Displays detailed information such as version, summary, and install date.
List filesrpm -ql {package-name}Lists the files included in an installed package.
Find file ownerrpm -qf {file-path}Shows which package owns the specified file.
Inspect .rpm filerpm -qip {package.rpm}Displays metadata from a .rpm file without installing it.
Verify packagerpm -V {package-name}Verifies that the installed files have not been tampered with.
Verify all packagesrpm -VaVerifies the files of all installed packages at once.
Verify signaturerpm --checksig {package.rpm}Verifies the GPG signature of a .rpm file.
Import GPG keyrpm --import {key-file}Imports a GPG public key. Required for signature verification.
dpkg (Debian / Ubuntu)
Installdpkg -i {package.deb}Installs or upgrades a .deb file. Fails with an error if dependencies are missing.
Removedpkg -r {package-name}Removes a package but leaves its configuration files on the system.
Purgedpkg -P {package-name}Removes a package along with its configuration files.
List all packagesdpkg -lLists all installed packages with their status flags.
Show detailsdpkg -s {package-name}Displays detailed information such as status, version, and dependencies.
List filesdpkg -L {package-name}Lists the files installed by a package.
Find file ownerdpkg -S {file-path}Shows which package owns the specified file.
Inspect .deb filedpkg -I {package.deb}Displays metadata from a .deb file without installing it.
List files in .debdpkg -c {package.deb}Lists the files contained in a .deb file.
Extract .debdpkg-deb -x {package.deb} {directory}Extracts the contents of a .deb file into the specified directory.
Resume configurationdpkg --configure -aResumes configuration of packages whose configuration was interrupted.
Fix broken dependenciesapt-get install -fFixes broken dependencies left after a dpkg operation.

Examples

# -----------------------------------------------
#  rpm: Installing a .rpm file and verifying it
# -----------------------------------------------

# Install a downloaded .rpm file on AlmaLinux
sudo rpm -ivh gojo-satoru-tools-1.0-1.el9.x86_64.rpm

# Verify that the installation succeeded
rpm -q gojo-satoru-tools

# List the files installed by the package
rpm -ql gojo-satoru-tools

Run the following command:

$ sudo rpm -ivh gojo-satoru-tools-1.0-1.el9.x86_64.rpm
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:gojo-satoru-tools-1.0-1.el9      ################################# [100%]
$ rpm -q gojo-satoru-tools
gojo-satoru-tools-1.0-1.el9.x86_64
rpm: Finding which package owns a file
# -----------------------------------------------
#  Find out which package provides a given command
# -----------------------------------------------

# Check which package owns /usr/bin/curl
rpm -qf /usr/bin/curl

# Display detailed information about that package
rpm -qi curl

Run the following command:

$ rpm -qf /usr/bin/curl
curl-7.76.1-29.el9.x86_64
$ rpm -qi curl
Name : curl
Version : 7.76.1
Release : 29.el9
Architecture: x86_64
Install Date: Mon 10 Mar 2025 09:00:00 AM JST
Group : Unspecified
Size : 695019
License : curl
Summary : A utility for getting files from remote servers (FTP, HTTP, and others)
rpm: Verifying package integrity
# -----------------------------------------------
#  Check whether installed files have been modified
# -----------------------------------------------

# Verify the files of the nginx package
rpm -V nginx

Run the following command:

$ rpm -V nginx
S.5....T.  c /etc/nginx/nginx.conf

The following example demonstrates this:

# Reading the output (meaning of each flag)
# S: File size has changed
# 5: MD5 checksum has changed (file contents were modified)
# T: Modification timestamp has changed
# c: Indicates a configuration file
# → /etc/nginx/nginx.conf shows changes because it was configured — this is expected
# → No output means the files have not been modified
dpkg: Installing a .deb file and fixing broken dependencies
# -----------------------------------------------
#  Install a downloaded .deb file on Ubuntu
# -----------------------------------------------

# Install megumi-fushiguro-tools_1.0_amd64.deb
sudo dpkg -i megumi-fushiguro-tools_1.0_amd64.deb

Run the following command:

$ sudo dpkg -i megumi-fushiguro-tools_1.0_amd64.deb
Selecting previously unselected package megumi-fushiguro-tools.
(Reading database ... 85432 files and directories currently installed.)
Preparing to unpack megumi-fushiguro-tools_1.0_amd64.deb ...
Unpacking megumi-fushiguro-tools (1.0) ...
dpkg: dependency problems prevent configuration of megumi-fushiguro-tools:
 megumi-fushiguro-tools depends on libshadow-style (>= 2.0); however:
  Package libshadow-style is not installed.

dpkg: error processing package megumi-fushiguro-tools (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 megumi-fushiguro-tools

The following example demonstrates this:

# A missing dependency error occurred
# Use apt-get install -f to resolve dependencies automatically
sudo apt-get install -f

Run the following command:

$ sudo apt-get install -f
Reading package lists... Done
Building dependency tree... Done
The following additional packages will be installed:
  libshadow-style
The following NEW packages will be installed:
  libshadow-style
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 512 kB of disk space will be used.
Do you want to continue? [Y/n] y
(The missing dependency is installed and configuration completes.)
dpkg: Inspecting installed packages
# -----------------------------------------------
#  Check installation status and display package details
# -----------------------------------------------

# List installed packages and filter for nginx
# Output format: ii = installed, rc = removed but config files remain
dpkg -l | grep nginx

# Display detailed information about nginx
dpkg -s nginx

# List the files installed by nginx
dpkg -L nginx | head -20

Run the following command:

$ dpkg -l | grep nginx
ii  nginx          1.24.0-1ubuntu1  amd64  high performance web server
$ dpkg -s nginx
Package: nginx
Status: install ok installed
Priority: optional
Section: httpd
Installed-Size: 126
Maintainer: Ubuntu Developers
Architecture: amd64
Version: 1.24.0-1ubuntu1
Depends: libpcre3, libssl3 (>= 3.0.0), zlib1g (>= 1:1.1.4)
Description: high performance web server
$ dpkg -L nginx | head -20
/.
/etc
/etc/nginx
/etc/nginx/sites-available
/etc/nginx/sites-available/default
/etc/nginx/sites-enabled
/usr
/usr/sbin
/usr/sbin/nginx
dpkg: Inspecting a .deb file without installing it
# -----------------------------------------------
#  Examine the contents of a .deb file before installing
# -----------------------------------------------

# Display metadata from nobara-kugisaki_2.0_amd64.deb
dpkg -I nobara-kugisaki_2.0_amd64.deb

# List the files contained in the .deb file
dpkg -c nobara-kugisaki_2.0_amd64.deb

Run the following command:

$ dpkg -I nobara-kugisaki_2.0_amd64.deb
 new Debian package, version 2.0.
 size 10485760 bytes: control archive=2048 bytes.
     512 bytes,    15 lines      control
 Package: nobara-kugisaki
 Version: 2.0
 Architecture: amd64
 Maintainer: Jujutsu <packages@jujutsu.example>
 Installed-Size: 40960
 Depends: libc6 (>= 2.35)
 Description: Nobara Kugisaki hammer tools
$ dpkg -c nobara-kugisaki_2.0_amd64.deb
drwxr-xr-x root/root   0 2025-01-01 00:00 ./
drwxr-xr-x root/root   0 2025-01-01 00:00 ./usr/
drwxr-xr-x root/root   0 2025-01-01 00:00 ./usr/bin/
-rwxr-xr-x root/root  40960 2025-01-01 00:00 ./usr/bin/kugisaki

Overview

rpm and dpkg are the low-level package management tools for RHEL-based and Debian-based Linux distributions, respectively. While higher-level tools such as dnf / yum and apt handle automatic dependency resolution and downloading from repositories, rpm and dpkg operate directly on .rpm or .deb files you already have on hand. They are particularly useful for installing packages in air-gapped environments, verifying package signatures, finding which package owns a specific file, and detecting tampering in installed files. When dpkg -i fails due to missing dependencies, running apt-get install -f to fix the dependency state is the standard follow-up procedure. In everyday use, dnf or apt is preferred; reach for rpm or dpkg when you need low-level inspection or verification. Some distributions, such as Arch Linux, use their own low-level tools like pacman.

If you find any errors or copyright issues, please .