Linux dnf Command: Manage RPM Distribution Packages
dnf is a command used to search, install, remove, and upgrade repository packages on Fedora/RHEL families as well as Rocky Linux/AlmaLinux. Depending on the distribution and version, the implementation and supported options of DNF may vary.
dnf command?
DNF uses repository metadata to calculate package candidates and dependencies. install also installs the required dependencies, and upgrade applies updates to installed packages. You can also install local RPM files, but for general tasks, DNF, which resolves dependencies, is more convenient than installing rpm directly.
Basic syntax
dnf [options] command [packages...]
The installed implementation and options may vary depending on the distribution. Check the description on your current system with man dnf.
Examples
Searching and checking package information
Check package names, descriptions, and repository candidates.
dnf search nginx dnf info nginx
Package Installation
Review the list of changing dependencies before installing.
sudo dnf install nginx
Check for updates
Check the list of available updates. It does not actually install them.
dnf check-update
Checking the Source and Version of a Package
dnf info shows the version, architecture, repository, and description of a package. You need to read it to distinguish between candidate versions before installation and installed versions.
dnf info bash
Examples of items to check in the output:
Name : bash Version : ... Architecture : x86_64 Repository : ...
Actual values vary depending on the distribution, active repositories, and timing. You can check update candidates with dnf check-update, but the exit code may indicate the presence of updates differently from normal success or failure, so you should consult the documentation in scripts. Before installing or removing, read the proposed list of dependency changes.
Main Options and Format
| Options/Format | Description |
|---|---|
search / info |
Find packages or display details. |
install / remove |
Install or remove packages. |
check-update / upgrade |
Check whether updates are available or apply them. |
repolist |
Check the enabled repositories. |
history |
View previous package transactions. |
Precautions when using
dnf upgrade can change running services and the kernel, so check the list of changes and whether a restart is needed. --allowerasing can remove existing packages to resolve conflicts. Do not arbitrarily add repositories or disable verification, and check the option differences with dnf help for the installed version.
Frequently Asked Questions
Which command should be used to install, dnf or rpm?
dnf is suitable for general installations and updates that manage repository dependencies. rpm is used when directly handling local package files and the installation database.
Official Documentation
The exact behavior and implementation differences of options can be found in the official dnf documentation.









