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 w Command: Show Logged-In Users and Their Processes

Linux w Command: Show Logged-In Users and Their Processes

Learn how to show Logged-In Users and Their Processes with the Linux w command, including practical examples, key options, and important precautions.

Linux date Command: Display and Format the Current Time

Linux date Command: Display and Format the Current Time

Learn how to display and Format the Current Time with the Linux date command, including practical examples, key options, and important precautions.

Linux realpath Command: Resolve Absolute and Canonical Paths

Linux realpath Command: Resolve Absolute and Canonical Paths

Learn how to use the Linux realpath command to resolve relative paths, symbolic links, and redundant path components, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Directory Structure Explained: Purpose of Major Directories

Linux Directory Structure Explained: Purpose of Major Directories

Understand the purpose of major Linux directories such as /etc, /var, /usr, /home, /proc, and /sys, and learn where common system files belong.

Linux Tutorial / PID and PPID Explained: Find and Manage Processes

Linux Tutorial / PID and PPID Explained: Find and Manage Processes

Understand what PID and PPID mean, inspect parent-child process relationships with ps and pgrep, and safely terminate a process you started yourself.

Linux id Command: Show User and Group IDs

Linux id Command: Show User and Group IDs

Learn how to show User and Group IDs with the Linux id command, including practical examples, key options, and important precautions.

Linux traceroute Command: Trace Routers on the Way to a Host

Linux traceroute Command: Trace Routers on the Way to a Host

Learn how to trace Routers on the Way to a Host with the Linux traceroute command, including practical examples, key options, and important precautions.

Linux cmp Command: Compare Files Byte by Byte

Linux cmp Command: Compare Files Byte by Byte

Learn how Linux cmp compares two files byte by byte, reports the first mismatch, runs silently in scripts, limits ranges, and differs from diff and checksums.

Linux history Command: Review and Reuse Shell Command History

Linux history Command: Review and Reuse Shell Command History

Learn how to use the Linux history command to review, search, reuse, and manage shell command history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux cp Command: Copy Files and Directories

Linux cp Command: Copy Files and Directories

Learn how to copy files and directories with Linux cp, control overwrites, preserve attributes, handle symlinks, and verify important copies.