Kahibaro
Discord Login Register

DNF (Fedora/RHEL)

Overview of DNF on Fedora/RHEL

DNF (dnf) is the default package manager on modern Fedora, RHEL, and CentOS Stream systems. It handles installing, updating, and removing RPM packages, resolving dependencies automatically, and working with software repositories.

DNF commands are generally run with sudo when they modify the system.

This chapter assumes you already understand general package management ideas from the parent chapter and focuses only on using DNF specifically.

Basic DNF Commands

Searching for Packages

To find packages related to a keyword:

dnf search firefox

This shows package names and short descriptions that match firefox.

To get detailed information about a specific package:

dnf info firefox

You’ll see:

Installing Packages

To install a package:

sudo dnf install firefox

You can install multiple packages at once:

sudo dnf install vim htop git

DNF shows:

Confirm with y (or y + Enter).

If a package is already installed, DNF will say so and do nothing, unless an update is available and you explicitly request it.

Removing Packages

To remove (uninstall) a package:

sudo dnf remove firefox

DNF will show:

Review carefully to avoid removing important packages accidentally.

Updating the System with DNF

Updating All Packages

To update all installed packages to the latest versions from enabled repositories:

sudo dnf update

On some systems dnf upgrade is equivalent:

sudo dnf upgrade

The process:

  1. DNF checks for available updates.
  2. Shows a summary of packages to be upgraded, downgraded, or installed as dependencies.
  3. Asks for confirmation.

Run this regularly to keep your system secure and up to date.

Updating Specific Packages

To update only one package:

sudo dnf update firefox

You can specify multiple packages:

sudo dnf update vim git

Checking for Available Updates

To see what updates are available without actually updating:

dnf check-update

This is useful if you just want to review pending updates first.

Working with Package Groups

Fedora/RHEL organize related software into groups (for example, “Development Tools”).

To list all groups:

dnf group list

You may see:

To get more details about a group:

dnf group info "Development Tools"

To install a group:

sudo dnf group install "Development Tools"

To remove a group:

sudo dnf group remove "Development Tools"

Group names are often case-sensitive and may require quotes if they contain spaces.

Managing Repositories with DNF

On Fedora/RHEL, repositories are defined in .repo files under /etc/yum.repos.d/. You don’t need to edit these manually as a beginner; DNF provides simple ways to enable or disable repos.

Listing Repositories

To list all configured repositories:

dnf repolist

To include disabled repositories as well:

dnf repolist all

Each repo has:

Enabling and Disabling Repositories

To temporarily use a repository for a single command:

sudo dnf --enablerepo=fedora-modular install some-package

This doesn’t permanently change the repo status.

To permanently enable a repo:

sudo dnf config-manager --set-enabled fedora-modular

To disable:

sudo dnf config-manager --set-disabled fedora-modular

If config-manager is not available, install it from dnf-plugins-core:

sudo dnf install dnf-plugins-core

Cleaning and Cache Management

DNF keeps a cache of metadata and downloaded packages to speed up future operations.

Cleaning the Cache

To see what can be cleaned:

dnf clean --help

Common options:

  sudo dnf clean metadata
  sudo dnf clean all

Use clean all if you’re short on disk space or if you suspect the cache is corrupted.

Re-downloading Metadata

To force DNF to refresh in a single command, combine clean with another operation:

sudo dnf clean metadata
sudo dnf update

Querying and Listing Packages

Listing Installed Packages

To list all installed packages:

dnf list installed

You can filter by a pattern:

dnf list installed "firefox*"

Listing Available Packages

To list packages that are available to install from enabled repos:

dnf list available

You can narrow down:

dnf list available "vim*"

Checking Which Package Provides a File

If you have a file or command and want to know which package it belongs to:

dnf provides /usr/bin/python3

or:

dnf provides "*/libcurl.so*"

This is often used when an error mentions a missing library or command.

Handling Dependencies and Problems

Automatically Removing Unneeded Dependencies

Over time, you may accumulate “orphaned” packages that were installed as dependencies but are no longer needed.

To remove these:

sudo dnf autoremove

Review the list carefully before confirming.

Downgrading a Package

If a new version causes issues, you can sometimes revert to an older version (if still available in repos):

sudo dnf downgrade firefox

Not every package will have older versions available; this depends on your distribution and repos.

Undoing a Transaction

DNF keeps a history of operations. To view it:

dnf history

Each transaction has an ID. To get details about one:

dnf history info 25

To try undoing a specific transaction:

sudo dnf history undo 25

To redo a transaction:

sudo dnf history redo 25

Undo/redo may not always be perfect (for example, if packages are no longer available), but it is very useful for recent mistakes.

Using DNF Plugins

DNF supports plugins to add extra features. Some common ones are provided by the dnf-plugins-core package.

Install the plugin collection:

sudo dnf install dnf-plugins-core

Examples of plugin commands (just a brief taste):

To see plugin-specific help:

dnf copr --help
dnf download --help

Practical Examples

A short set of real-world commands you might use on Fedora/RHEL:

  sudo dnf install vim htop curl git
  sudo dnf update
  dnf check-update
  dnf search player
  sudo dnf install vlc
  dnf provides "*/ssh-copy-id"
  sudo dnf install openssh-clients

These examples cover the most common day-to-day use of DNF on Fedora and RHEL-based systems.

Views: 25

Comments

Please login to add a comment.

Don't have an account? Register now!