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 -qfordnf provides. - If the lists appear different:
dnfcombines and displays repository metadata, whilerpmqueries 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.









