dotlinux blog

How to Use dnf5 Command for Fedora Package Management

For years, Fedora users have relied on the venerable dnf command as the backbone of their system administration. It's the tool we use to install new software, update our systems, and keep everything running smoothly. But evolution is a constant in the world of open source, and Fedora is introducing its next-generation package manager: dnf5.

dnf5 is a ground-up rewrite of the DNF package manager, designed to be faster, more efficient, and more correct. It addresses long-standing performance issues and introduces a cleaner codebase for future development. While the classic dnf command is still present and supported, dnf5 is the future, and Fedora 41 and later are expected to use it by default.

This blog post is your comprehensive guide to using the dnf5 command. Whether you're a seasoned Fedora admin or a newcomer, we'll walk you through everything from basic installation to advanced usage, helping you make a smooth transition to this modern package management tool.


2026-03

Table of Contents#

  1. What is dnf5?
  2. Installing dnf5
  3. Basic dnf5 Commands
    1. Searching for Packages
    2. Installing Packages
    3. Removing Packages
    4. Updating Packages
  4. System Maintenance with dnf5
    1. Upgrading the System
    2. Managing Repository Data
    3. System Cleanup
  5. Advanced dnf5 Usage
    1. Working with Package Groups
    2. Viewing Package Information
    3. Investigating Dependencies
    4. Handling Transactions
  6. Key Differences from Classic DNF
  7. Conclusion
  8. References

What is dnf5?#

dnf5 is the next major version of the DNF package manager, which is used in Fedora, Red Hat Enterprise Linux, and other RPM-based distributions. It's not just an update; it's a complete rewrite in C++ (whereas the original DNF is written in Python). This architectural change brings several key benefits:

  • Improved Performance: dnf5 is significantly faster than its predecessor, especially for operations like dependency resolution and metadata loading. Users can expect quicker search, install, and update times.
  • Reduced Memory Usage: The new implementation is more memory-efficient.
  • Better Dependency Solver: It features a new, more advanced dependency solver (libsolv) that is more robust and accurate.
  • Cleaner Codebase: The rewrite allowed developers to address technical debt and create a more maintainable codebase for future features.

It's important to note that dnf5 is designed to be a drop-in replacement for dnf. Most commands you use with dnf will work the same way with dnf5, making the transition easy.

Installing dnf5#

As of the time of writing, dnf5 is available in the Fedora repositories but is not yet the default. You can install it alongside the classic dnf.

1. Update your system first:

sudo dnf update

2. Install the dnf5 package:

sudo dnf install dnf5

Once installed, you can start using the dnf5 command immediately. You will have both dnf and dnf5 available on your system.

Note: Some plugins or specific features from classic DNF might not be fully ported to dnf5 yet. For critical system operations, it's often safer to use the default dnf until dnf5 becomes the official default.

Basic dnf5 Commands#

The basic workflow for package management remains unchanged. If you know how to use dnf, you already know 90% of dnf5.

Searching for Packages#

Before installing anything, you often need to search for the correct package name.

Search for a package by keyword:

dnf5 search neofetch

This will list all packages whose name or description contains "neofetch".

List all available packages (can be a very long list):

dnf5 list available

List all installed packages:

dnf5 list installed

Installing Packages#

Installing a package is straightforward. You often need sudo privileges because you are making system-wide changes.

Install a single package:

sudo dnf5 install neofetch

Install multiple packages at once:

sudo dnf5 install htop vim git

Removing Packages#

To remove an installed package, use the remove command.

Remove a package:

sudo dnf5 remove neofetch

This command removes the specified package but may leave behind dependencies that are no longer needed.

Remove a package and its unused dependencies:

sudo dnf5 autoremove neofetch

The autoremove command is the preferred way to cleanly uninstall software.

Updating Packages#

Keeping your software updated is crucial for security and stability.

Check for available updates:

dnf5 check-update

This lists all packages that have updates available without performing the update.

Update a specific package:

sudo dnf5 update firefox

Update all packages on the system:

sudo dnf5 update

This is the standard command to fully update your Fedora system.

System Maintenance with dnf5#

Upgrading the System#

While dnf5 update handles regular updates, Fedora also has major version releases. The upgrade process is also managed by dnf5.

Upgrade to a new Fedora release:

sudo dnf5 system-upgrade download --refresh --releasever=41
sudo dnf5 system-upgrade reboot
  • The first command downloads all packages for the new release (in this example, Fedora 41).
  • The second command reboots the system to begin the upgrade process.

Managing Repository Data#

dnf5 caches metadata from enabled repositories to speed up operations. Sometimes you need to refresh this cache.

Refresh the repository metadata cache:

sudo dnf5 clean expire-cache

This is the dnf5 equivalent of sudo dnf makecache.

List all enabled repositories:

dnf5 repolist

System Cleanup#

Over time, cached package files can consume disk space. dnf5 provides tools to clean them up.

Remove all cached package files:

sudo dnf5 clean packages

Remove all cached metadata and package files (a more thorough cleanup):

sudo dnf5 clean all

Remove orphaned dependencies: After uninstalling various packages, you may have libraries and other dependencies that are no longer needed by any installed software. To remove them, use:

sudo dnf5 autoremove

Advanced dnf5 Usage#

Working with Package Groups#

Fedora often bundles related packages into groups, such as "Development Tools" or "Office Suite."

List all available package groups:

dnf5 group list

Install a package group:

sudo dnf5 group install "Development Tools"

This is a very common command for setting up a development environment.

Viewing Package Information#

You can get detailed information about any package (installed or available).

Show detailed information about a package:

dnf5 info firefox

This displays the version, release, size, description, and URL for the package.

List the files contained in an installed package:

dnf5 repoquery -l firefox

Investigating Dependencies#

Understanding package relationships is key for troubleshooting.

List a package's dependencies (what it requires):

dnf5 repoquery --requires firefox

Find which package provides a specific file or dependency:

dnf5 provides /bin/ls

This is an incredibly useful command for figuring out which package you need to install to get a specific file or library.

Handling Transactions#

dnf5 keeps a history of all transactions (install, update, remove). You can review this history.

View transaction history:

dnf5 history

Undo a specific transaction (by its ID):

sudo dnf5 history undo 23

This will attempt to reverse the changes made in transaction number 23.

Key Differences from Classic DNF#

While dnf5 aims for compatibility, there are some notable differences:

  1. Command Aliases: Some command aliases are different. For example, the old dnf repoquery command's functionality is now integrated directly into dnf5 (as seen with dnf5 repoquery), but some subcommands might differ.
  2. Configuration Files: dnf5 uses a new configuration file location (/etc/dnf5/dnf5.conf) instead of the classic /etc/dnf/dnf.conf. It also uses /etc/dnf5/libdnf5.conf for low-level settings.
  3. Plugins: The plugin system is different. Plugins written for classic DNF are not compatible with dnf5 and need to be ported.
  4. Output Format: The output of some commands is cleaner and more condensed.
  5. Strict Aliasing: dnf5 is stricter about package naming. You can no longer use the -y flag without a package name to mean "the entire system."

Always refer to the man pages (man dnf5) for the most accurate and up-to-date information.

Conclusion#

dnf5 represents a significant step forward for package management on Fedora. Its focus on speed, efficiency, and a maintainable codebase ensures that Fedora remains a cutting-edge distribution. The transition for users is deliberately smooth, with most classic dnf commands working as expected.

By familiarizing yourself with dnf5 now, you're preparing for the future of Fedora. Start by using it for non-critical tasks, explore its features, and enjoy the performance improvements. As it matures and becomes the default, you'll be ahead of the curve.

Happy packaging!


References#

  1. Fedora Wiki: DNF5 - The official project page for dnf5 on the Fedora Wiki.
  2. dnf5 GitHub Repository - The source code and issue tracker for dnf5.
  3. Man Page: dnf5 - Official documentation for the dnf5 command (man dnf5).
  4. Fedora Magazine: Trying DNF5 - Articles and tutorials from Fedora Magazine.