How to List Installed Packages on Rocky Linux

Packages installed on Rocky Linux can be checked using dnf and rpm. Usually, dnf is used as it shows repository information and dependencies together, while rpm is convenient for querying the exact RPM database or verifying the owner of files.

Check the full list of installed packages

DNF (Dandified YUM) is the package manager for Rocky Linux. The following command displays the installed package names, versions, and installation sources in a table format.

dnf list --installed

To simply check only the package names registered in the RPM database, use the following command.

rpm -qa | sort

If the results are long, you can paginate them with less or find only the necessary names with grep.

rpm -qa | sort | less
rpm -qa | grep -i postgresql

Check installation status and information for a specific package

When you know the name

rpm -q outputs the exact name and version if the package is installed, and if it is not installed, it returns an error message and a non-zero exit status.

rpm -q curl
dnf info --installed curl

When looking for a command or a file's package

You can check which package an existing file was installed from using rpm -qf. For commands with symbolic links, it is more accurate to find the actual path first using readlink -f and then query.

rpm -qf /usr/bin/curl
rpm -qf "$(readlink -f "$(command -v python3)")"

To find repository packages that provide commands or files that are not yet installed, use dnf provides.

dnf provides '*/semanage'

View version, installation time, and source in detail

Using RPM's query format, you can output only the needed items in the desired order. The example below separates package name, epoch/version/release, and architecture with tabs.

rpm -qa --qf '%{NAME}\t%{EPOCHNUM}:%{VERSION}-%{RELEASE}\t%{ARCH}\n' | sort

The order of recently installed packages can be checked as follows.

rpm -qa --last | head -n 30
Purpose of checking Recommended commands
Full list of installed packages dnf list --installed or rpm -qa
Check a specific package rpm -q package-name
Package details dnf info --installed package-name
Package owning a file rpm -qf file-path
Search for file-providing packages dnf provides '*/filename'
Recent installation order rpm -qa --last

Check directly installed packages and change history

Items installed by the user

Packages recorded by DNF as installed at the user's request can be viewed with the following command. Excluding items automatically installed as dependencies is useful when determining the server's purpose or reviewing items for cleanup.

dnf history userinstalled

However, if RPM files were directly installed in the past or the system was migrated, the records may not be complete. Do not automatically delete packages based solely on this result; check the services and dependencies as well.

DNF transaction history

The history of installation, update, and deletion operations and the detailed information of specific transactions can be checked as follows.

dnf history
dnf history info transaction_ID

Check installation files and configuration changes

rpm -V compares the recorded information at the time of installation with the current file size, checksum, permissions, owner, and more. If nothing is displayed, it means no differences were found in the items checked.

sudo rpm -V openssh-server

Configuration files under /etc will be marked as different even if intentionally changed by the administrator. Do not restore immediately upon seeing results; instead, compare with change management records and backups.

Keep a list of server packages in a file

For troubleshooting or migration, it is helpful to save the name, version, and architecture as text so that you can easily compare between two points in time or two servers.

rpm -qa --qf '%{NAME}\t%{EPOCHNUM}:%{VERSION}-%{RELEASE}\t%{ARCH}\n' | sort > installed-packages.tsv

This list is a record of the state at that time and is not an installation script that can be run as-is on another server. If the major version of Rocky Linux, active repositories, and module streams differ, you may not get the same version, so recovery procedures must be tested separately.

Frequently occurring problems

  • If it says the command does not exist: Some DNF plugins may be missing in a minimal installation. First, check the package that provides the command.
  • If the name is different from what you expect: The executable name and the package name may not be the same, so use rpm -qf or dnf provides.
  • If the lists appear different: dnf combines and displays repository metadata, while rpm queries the local RPM database directly. Choose the tool according to your comparison purpose.
  • If you encounter a database error: First, check whether another package operation is in progress, and do not arbitrarily delete lock files or the database.

Reference Documents

More in This Category
How to Change the Hostname on Rocky Linux

How to Change the Hostname on Rocky Linux

Learn how to change a Rocky Linux hostname with hostnamectl, verify the persistent setting, and check name resolution and services afterward.

How to Configure SELinux Modes on Rocky Linux

How to Configure SELinux Modes on Rocky Linux

Check and change SELinux enforcing, permissive, and disabled modes on Rocky Linux, understand temporary and persistent changes, and troubleshoot denials safely.

How to Install MariaDB on Rocky Linux

How to Install MariaDB on Rocky Linux

Install MariaDB on Rocky Linux, enable the database service, complete the initial security setup, create a database and account, and verify access.

How to List Installed Packages on Rocky Linux

How to List Installed Packages on Rocky Linux

Use DNF and RPM to list, search, count, and inspect installed packages on Rocky Linux and identify which package owns a file.

How to Manage firewalld on Rocky Linux: Zones, Services, and Ports

How to Manage firewalld on Rocky Linux: Zones, Services, and Ports

Learn how to manage firewalld on Rocky Linux with firewall-cmd, including active zones, services, custom ports, runtime and permanent rules, rich rules, and NetworkManager integration. The guide emphasizes a safe workflow for remote SSH servers.

How to Use DNF on Rocky Linux: Packages, Repositories, and Updates

How to Use DNF on Rocky Linux: Packages, Repositories, and Updates

Use DNF on Rocky Linux to search, install, remove, update, and inspect packages and repositories while keeping package-management changes controlled.

How to Install PostgreSQL on Rocky Linux

How to Install PostgreSQL on Rocky Linux

Install PostgreSQL on Rocky Linux, initialize the database cluster, enable the service, create a database and user, and review network and authentication settings.

How to Change the System Language and Locale on Rocky Linux

How to Change the System Language and Locale on Rocky Linux

Learn how to check and change the system-wide language and locale on Rocky Linux with localectl and glibc language packs. This guide also explains session-only changes, LANG and LC_* precedence, and troubleshooting for broken Korean characters.

How to Install a GUI and Remote Desktop on Rocky Linux

How to Install a GUI and Remote Desktop on Rocky Linux

Install a graphical desktop on Rocky Linux, select the graphical boot target, configure remote access, and review firewall and security considerations.

How to Configure a Static IP Address on Rocky Linux

How to Configure a Static IP Address on Rocky Linux

Configure and verify a static IPv4 address on Rocky Linux with NetworkManager, including the gateway, DNS servers, connection profile, and safe remote-change checks.