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.

More in This Category
Linux unxz Command: Decompress xz Files

Linux unxz Command: Decompress xz Files

Learn how to decompress xz Files with the Linux unxz command, including practical examples, key options, and important precautions.

Linux ls Command: List Files and Directories

Linux ls Command: List Files and Directories

Learn how to use the Linux ls command to list files and directories with permissions, sizes, timestamps, and sorting options, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Linux Tutorial / Navigate Directories with pwd, ls, cd, and tree

Use pwd, ls, cd, and tree to find your current location, inspect directories, navigate paths, and check where each command takes you.

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.

Bash Command Operators Explained: ;, &&, ||, &, and |

Bash Command Operators Explained: ;, &&, ||, &, and |

Understand how Bash operators run commands sequentially, conditionally, in the background, or through pipelines, with practical examples and precedence guidance.

Linux split Command: Divide Large Files into Smaller Parts

Linux split Command: Divide Large Files into Smaller Parts

Learn how to divide Large Files into Smaller Parts with the Linux split command, including practical examples, key options, and important precautions.

Essential Linux Commands: A Practical Reference by Task

Essential Linux Commands: A Practical Reference by Task

Browse essential Linux commands by task, including help, files, text processing, permissions, processes, networking, packages, storage, and system administration.

Linux fdisk Command: Inspect and Edit Disk Partitions

Linux fdisk Command: Inspect and Edit Disk Partitions

Learn how to inspect and Edit Disk Partitions with the Linux fdisk command, including practical examples, key options, and important precautions.

How to Check IP Addresses on Linux

How to Check IP Addresses on Linux

Learn how to check private and public IP addresses on Linux, identify the active interface and route, and distinguish IPv4, IPv6, and externally visible addresses.

Linux jobs Command: List Jobs in the Current Shell

Linux jobs Command: List Jobs in the Current Shell

Learn how to list Jobs in the Current Shell with the Linux jobs command, including practical examples, key options, and important precautions.