Linux commands
Browse topics

Installing packages on Fedora and RHEL with dnf

Version
unversioned
Review
Draft

Summary#

dnf installs, upgrades and removes RPM packages on Fedora, RHEL and related distributions. rpm queries what is installed.

Syntax#

sh
sudo dnf install nginx
sudo dnf upgrade
sudo dnf remove nginx
dnf search nginx
dnf info nginx
dnf provides /usr/sbin/nginx
rpm -q bash
rpm -ql bash

dnf upgrade updates installed packages. provides finds the package that supplies a file. rpm -ql lists the files of an installed package.

Example#

This example only reads the package database on an RPM-based system.

sh
(
  set -eu
  rpm -q --qf '%{NAME}\n' bash
  rpm -q dl-no-such-package || echo "status $?"
)

Expected output#

Text
bash
package dl-no-such-package is not installed
status 1

Common mistakes#

No match for argument means no enabled repository provides that name; check the spelling with dnf search and the repository list with dnf repolist. Read the transaction summary before confirming, since removing one package can remove others that depend on it. Mixing packages from another distribution release can break upgrades. On older systems yum is the command; on current ones it is a compatibility name for DNF.

Version applicability#

This entry describes DNF5 on Fedora 44. DNF4, used by RHEL 8 and 9, differs in some commands and messages.

Sources#

Attribution
DevLookup contributors
License
CC-BY-4.0