DNF5 Install Command Guide for Fedora

DNF5 is Fedora’s default package manager, providing faster performance and improved dependency resolution compared to its predecessor. This guide covers practical examples for installing packages on Fedora Linux, from single packages to entire software groups.

By the end of this guide, you will be able to search for software, verify package details, and install packages using various DNF5 commands and options.

Preparation Steps

Before installing software, verify your environment is ready and your system is up to date. These steps ensure package compatibility and reduce the chance of conflicts during installation.

Verify Your Fedora Version

First, confirm you are running a supported Fedora release. The commands in this guide apply to Fedora 41 and later, which use DNF5 by default:

cat /etc/os-release

Expected output includes lines showing your Fedora version:

NAME="Fedora Linux"
VERSION="43 (Workstation Edition)"
ID=fedora
VERSION_ID=43

Confirm DNF5 Is Active

Next, verify that DNF5 is installed and accessible on your system:

dnf --version

The output confirms you are using DNF5:

dnf5 version 5.2.17.0
dnf5 plugin API version 2.0
libdnf5 version 5.2.17.0

If you see a version starting with 4.x, you are running DNF4 (used on RHEL, Rocky Linux, and AlmaLinux). Some command syntax differs between versions.

Update Your System

Updating your system ensures you have the latest package definitions and security patches. This step minimizes dependency conflicts when installing new software:

sudo dnf upgrade --refresh

The --refresh flag forces DNF to download fresh metadata from all enabled repositories before calculating updates. For automated system updates, see our guide on how to install dnf-automatic on Fedora.

Search for Packages

Before installing software, you often need to find the correct package name. The dnf search command searches package names and descriptions for matching keywords.

Find Packages by Keyword

To search for packages related to “editor”:

dnf search editor

DNF5 displays matching packages in a compact format:

Matched fields: name, summary
 dconf-editor.x86_64    Configuration editor for dconf
 gedit.x86_64           A text editor for the GNOME desktop
 vim-enhanced.x86_64    A version of the VIM editor which includes recent enhancements
 nano.x86_64            A small text editor

The dnf search command does not require sudo because it only reads package metadata without modifying the system.

Find Which Package Provides a File

If you need a command or file that is not installed (such as semanage for SELinux management), use dnf provides to find which package contains it:

dnf provides '*bin/semanage'

Example output:

policycoreutils-python-utils-3.9-5.fc43.noarch : SELinux policy core python utilities
Repo         : fedora
Matched From : 
Provide      : policycoreutils-python-utils = 3.9-5.fc43

Use wildcards with dnf provides when searching for commands. The pattern '*bin/command' matches files in common binary directories like /usr/bin and /usr/sbin.

View Package Details

The dnf info command displays detailed information about a specific package, including its version, repository source, and description. This helps you verify you are installing the correct package before proceeding.

Display Package Information

To view details for the vim-enhanced package:

dnf info vim-enhanced

Example output:

Available packages
Name           : vim-enhanced
Epoch          : 2
Version        : 9.1.1972
Release        : 1.fc43
Architecture   : x86_64
Download size  : 2.0 MiB
Installed size : 4.2 MiB
Repository     : updates
Summary        : A version of the VIM editor which includes recent enhancements

The info command requires the exact package name. If unsure, use dnf search first to find the correct name.

Install Packages

The dnf install command resolves dependencies automatically, ensuring all required libraries and components are installed alongside your target software.

Install a Single Package

To install a single package, specify its name after the install command:

sudo dnf install <package_name>

For example, to install the Vim text editor:

sudo dnf install vim

DNF displays a transaction summary showing which packages will be installed and their sizes, then prompts for confirmation before proceeding.

Install Multiple Packages at Once

You can install several packages in a single transaction by listing them separated by spaces. This approach saves time because DNF resolves all dependencies together:

sudo dnf install vim nano htop

Install Without Confirmation

For scripting or automation, use the -y flag to automatically answer “yes” to all prompts:

sudo dnf install -y vim

Reinstall a Package

If a package has corrupted or missing files, reinstalling it restores the original files without changing configuration:

sudo dnf reinstall vim

Advanced Installation Options

DNF provides several flags to customize installation behavior. These options help resolve conflicts, handle missing packages, and prepare for offline installations.

Useful Installation Flags

  • --allowerasing: Resolves conflicts by removing packages that block the installation. Use with caution as this may remove packages you need.
  • --skip-unavailable: Continues the transaction even if some requested packages are not found in any enabled repository.
  • --skip-broken: Skips packages that cannot be installed due to dependency problems while installing the rest.
  • --offline: Downloads packages and prepares them for installation during the next system reboot. Useful for kernel updates or major changes.

Handle Dependency Conflicts

If one package has a dependency conflict, DNF may refuse to proceed with the entire transaction. Use the --skip-broken flag to install available packages while skipping problematic ones:

sudo dnf install vim nano htop --skip-broken

Resolve Package Conflicts

When a new package conflicts with an existing one, use --allowerasing to let DNF remove the blocking package:

sudo dnf install vim-enhanced --allowerasing

DNF displays which packages it needs to remove before proceeding, giving you a chance to cancel if the removal is unacceptable.

Install Package Groups

Package groups bundle related software for specific tasks like development, multimedia production, or server administration. Installing a group saves time compared to installing packages individually.

List Available Groups

To see all available package groups:

dnf group list

Example output showing available groups:

ID                          Name                                        Installed
development-tools           Development Tools                                  no
kde-desktop                 KDE                                                no
libreoffice                 LibreOffice                                        no
sound-and-video             Sound and Video                                    no

For detailed information about working with groups, including viewing group contents and optional packages, see our dedicated guide on DNF5 group commands on Fedora.

Install a Package Group

To install the “Development Tools” group, which includes compilers and build utilities:

sudo dnf group install "Development Tools"

You can also use the group ID instead of the full name:

sudo dnf group install development-tools

Manage Repositories

Before installing third-party software, you may need to add additional repositories. Fedora includes official repositories by default, but some software requires external sources.

Add a Repository

To add a new repository from a .repo file URL, use the config-manager plugin:

sudo dnf config-manager addrepo --from-repofile=https://example.com/repo.repo

DNF5 uses addrepo (without dashes) rather than the DNF4 syntax --add-repo.

List Configured Repositories

To view all repositories, including disabled ones:

dnf repo list --all

Troubleshooting Installation Issues

This section covers solutions to common problems you may encounter when installing packages with DNF5.

Package Not Found

If DNF reports that a package does not exist, try these steps:

  1. Refresh the repository cache: sudo dnf makecache
  2. Search for the correct package name: dnf search <keyword>
  3. Check if the package is in a disabled repository: dnf repo list --all

Dependency Conflicts

When packages have conflicting dependencies, DNF displays the conflict details. You have several options:

  • Use --allowerasing to let DNF remove conflicting packages
  • Use --skip-broken to skip the problematic package and install the rest
  • Identify and manually remove the conflicting package first

Conclusion

DNF5 streamlines package installation on Fedora with faster operations and automatic dependency resolution. You now know how to search for packages, verify their details, and install them using various methods and options. For major version upgrades between Fedora releases, refer to our guide on DNF5 system upgrade commands.

Leave a Comment