Table of Contents
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 firefoxYou’ll see:
- Name and version
- Repository it comes from
- Summary and description
- Architecture (e.g.,
x86_64,noarch) - Size
Installing Packages
To install a package:
sudo dnf install firefoxYou can install multiple packages at once:
sudo dnf install vim htop gitDNF shows:
- What will be installed
- Dependencies that will be pulled in
- Download size and total installed size
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 firefoxDNF will show:
- The package being removed
- Any dependencies that were installed only for that package and are no longer needed
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 upgradeThe process:
- DNF checks for available updates.
- Shows a summary of packages to be upgraded, downgraded, or installed as dependencies.
- 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 firefoxYou can specify multiple packages:
sudo dnf update vim gitChecking for Available Updates
To see what updates are available without actually updating:
dnf check-updateThis 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 listYou may see:
- Installed groups
- Available groups
- Environment groups (larger collections, like “Workstation”)
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 repolistTo include disabled repositories as well:
dnf repolist allEach repo has:
- An ID (short name used in commands)
- A human-readable name
- A status (enabled/disabled)
Enabling and Disabling Repositories
To temporarily use a repository for a single command:
sudo dnf --enablerepo=fedora-modular install some-packageThis doesn’t permanently change the repo status.
To permanently enable a repo:
sudo dnf config-manager --set-enabled fedora-modularTo 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-coreCleaning 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 --helpCommon options:
- Clean metadata only (information about packages):
sudo dnf clean metadata- Clean all cached data (metadata and downloaded packages):
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 updateQuerying and Listing Packages
Listing Installed Packages
To list all installed packages:
dnf list installedYou 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 availableYou 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/python3or:
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 autoremoveReview 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 firefoxNot 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 historyEach transaction has an ID. To get details about one:
dnf history info 25To try undoing a specific transaction:
sudo dnf history undo 25To redo a transaction:
sudo dnf history redo 25Undo/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-coreExamples of plugin commands (just a brief taste):
dnf copr— work with COPR (Fedora’s community build system)dnf config-manager— manage repos (already used above)dnf download— download packages without installing
To see plugin-specific help:
dnf copr --help
dnf download --helpPractical Examples
A short set of real-world commands you might use on Fedora/RHEL:
- Install common tools:
sudo dnf install vim htop curl git- Keep your system updated:
sudo dnf update- Check what will be updated without changing anything:
dnf check-update- Search for a media player and install one:
dnf search player
sudo dnf install vlc- Find which package provides a missing command:
dnf provides "*/ssh-copy-id"
sudo dnf install openssh-clientsThese examples cover the most common day-to-day use of DNF on Fedora and RHEL-based systems.