Home Package managementDNF5 Commands Examples For Managing Packages In Linux

DNF5 Commands Examples For Managing Packages In Linux

How to Use DNF5 to Manage Packages in Fedora, RHEL, AlmaLinux, Rocky Linux

By sk
Published: Updated: 618 views 13 mins read

DNF5 is the Fedora's Next-gen package manager, replacing the older DNF and YUM tools. It helps users install, update, and remove software packages on Fedora, RHEL, AlmaLinux and Rocky Linux systems. This guide provides practical examples of essential DNF5 commands to assist the users in managing their software efficiently.

It does not matter if you have used Fedora for years or if you are new. This guide will teach you all you need to know to use DNF5 well.

All commands given below are tested and verified in the latest Fedora 42 Linux. However, the DNF5 Commands usage is same for RHEL 10, AlmaLinux 10 and Rocky Linux 10.

Getting Started with DNF5: Important DNF5 Commands for Everyday Software Management

The general syntax of DNF5 command is:

dnf5 [OPTIONS] COMMAND [PACKAGE...]

Here, OPTIONS indicates the flags that change how the command works (like -y for automatic confirmation), COMMAND tells it what to do (like install, update), and PACKAGE is the name of the program(s) you want to work with.

For many users, the shift to DNF5 may seem subtle at first. Fedora 41 and later releases will set the /usr/bin/dnf symlink to point directly to /usr/bin/dnf5 to maintain backward compatibility.

While the /usr/bin/dnf command will point to dnf5 in Fedora 41+, always writing dnf5 in commands is recommended.

Now, we will learn some useful dnf5 commands with practical examples for the most common software management tasks in Fedora, CentOS Stream, RHEL and its clones such as AlmaLinux, Rocky Linux.

Installing Packages

To install a new package, for example Vim, you would type:

sudo dnf5 install vim -y

The -y option automatically says yes to any questions, so you don't have to type anything during install.

To install multiple packages at once, do:

sudo dnf5 package1 package2

Example:

sudo dnf5 install vim nano -y

Updating Packages and Your System

Keeping software up-to-date is very important for safety. DNF5 has commands to update single programs or your whole system.

To update all installed packages:

sudo dnf5 update

To update a specific package, like vim:

sudo dnf5 update vim

To update your entire system to the newest versions of all programs, including anything new they need:

sudo dnf5 upgrade

These commands make sure your system gets the newest features, runs better, and has the latest safety fixes.  

Removing Packages

When you don't need a package anymore, the remove command takes it off your computer along with anything it needed that other packages don't use anymore.

To remove a package, for example Vim:

sudo dnf5 remove vim

Searching for Packages

To find software packages in the active software repositories, the search command is very important. It shows a list of packages whose names or descriptions match what you typed.

dnf5 search vim

This helps users find packages before they install them.

Listing Installed Packages

To see a full list of all packages currently on your system, you use the list command.

dnf5 list

It's worth noting a small change in how DNF5 acts with the --available option for the list command. In DNF4, this option usually showed only programs not installed or newer versions.

DNF5, however, when --available is used, looks at all versions available in active software lists, no matter what version you have installed.

This gives a fuller picture but might mean users need to get used to more information.

Viewing Package Information

For full details about a package, like its version, what it does, what it needs, and where it came from, you use the info command.

To get information about Vim, run:

dnf5 info vim

DNF5's info command has also seen some changes, where --all is now the normal way it works, and --updates is now --upgrades.

These changes make the command simpler by showing common info by default, and helping users find clearer options.

Cleaning the DNF5 Cache

Over time, DNF5 collects saved data, including downloaded program files and info about them. The clean command helps clear space on your computer by deleting this saved info.

To clean all DNF5 cache:

sudo dnf5 clean all

The normal user cache directory is now ~/.cache/libdnf5, and the normal root cache directory is /var/cache/libdnf5. This new way of storing things helps keep saved data tidy.

Managing Software Repositories

DNF5 lets you manage software repositories, which are where packages are downloaded from.

To list all active software repositories:

dnf5 repo list

While repolist remains an old name that still works, DNF5 now makes this standard under the repo command as dnf5 repo list. Using the clearer repo list is better for future versions.

To enable a repository:

sudo dnf5 config-manager --set-enabled repository-name

To disable a software repository:

sudo dnf5 config-manager --set-disabled repository-name

A big improvement in DNF5's config-manager command is how it changes software repository settings. Instead of directly changing the actual .repo files, DNF5 now makes small "drop-in override files".

This helps make changes that don't break things, making it much easier to undo changes, handle settings from different places, and stop accidentally writing over original files when updating packages.

Downgrading Packages

Sometimes, you might need to go back to an older version of a package. The downgrade command makes this process easier.

To downgrade Vim:

sudo dnf5 downgrade vim

Checking Package Dependencies

To check what other packages a specific package needs to run, you use the deplist command. This can be useful for fixing problems or knowing what a program needs.

To list all dependencies Vim needs, run:

dnf5 deplist vim

Essential DNF5 Commands Cheatsheet

The table below summarizes these important DNF5 commands for quick reference:

CommandWhat it doesExample
install <package>Puts new software packages on your system.sudo dnf5 install firefox -y
updateUpdates all installed packages.sudo dnf5 update
update <package>Updates a specific package.sudo dnf5 update firefox
remove <package>Takes software and what it needs off your system.sudo dnf5 remove firefox
search <term>Finds packages matching a word.dnf5 search browser
listShows all packages installed on your system.dnf5 list
info <package>Shows full details about a package.dnf5 info firefox
clean allRemoves all saved package data.sudo dnf5 clean all
repo listLists all active software repositories.dnf5 repo list
config-manager --set-enabled <repo>Turns on a software list (repository).sudo dnf5 config-manager --set-enabled fedora-updates
config-manager --set-disabled <repo>Turns off a software repository.sudo dnf5 config-manager --set-disabled fedora-testing
upgradeUpdates your entire system.sudo dnf5 upgrade
downgrade <package>Goes back to an older version of a package.sudo dnf5 downgrade firefox
deplist <package>Lists all packages needed by a package.dnf5 deplist firefox

Advanced DNF5 Commands Usage: Groups and System Upgrades

Beyond basic software management, DNF5 offers advanced features for managing groups of programs and making big system updates smoother.

Working with Package Groups

DNF5 brings big steps forward in managing package groups, which are organized sets of related software.

These groups make it easier to install programs for certain jobs, like setting up a "Development Tools" environment or configuring "KDE Plasma Workspaces."  

To start working with groups, you can list all available groups on your system:

dnf5 group list

This command shows an organized list of groups you can install. Some groups, often with special software, are hidden by default. To see these, you can use the --hidden option:  

dnf5 group list --hidden

Looking at hidden groups can help you find software groups made for advanced or very specific jobs.  

Once you find a group, you can see full details about it, like what it does, packages that must be installed with it, and extra packages you can choose for more features:

dnf5 group info "<group-name>"

For example, to see details about the "Development Tools" group:

dnf5 group info development-tools

Installing a package group is easy.

For instance, you can install all development packages with a single command:

sudo dnf5 group install development-tools

This command installs GCC, Git, and other dev tools at once.

Many old names from DNF (like groupinstall, grouplist) and subcommands (like group mark install) are no longer used.

This move to clearer subcommands (like group list instead of grouplist) aims to make things less confusing and give a more consistent way to use commands.

Also, DNF5 adds new options like --contains-pkgs, which lets users find groups by specific programs, making it easier for advanced users to find and control things.

Performing a Fedora Upgrade with DNF5

The dnf5 system-upgrade command is a strong, built-in tool made to make the process of updating from one Fedora version to another much easier.

This command makes sure the process is fast, easy to use, and has fewer risks. It automatically downloads and installs needed programs and makes changes when your computer restarts.

The change of system-upgrade from an add-on to a built-in command makes it a main, important part of DNF5.

The system update process using DNF5 involves a few steps:

1. Install the Plugin (if needed):

Often already installed on Fedora 41+, but running this makes sure.

sudo dnf5 install dnf5-plugin-system-upgrade

This command makes sure you have the tools needed for the update.

2. Download Upgrade Packages:

sudo dnf5 system-upgrade download --releasever=<target_version>

Replace <target_version> with the Fedora version you want (e.g., 42).

This command gets all the packages needed for the new Fedora version.

3. Fix Problems (if any):

sudo dnf5 system-upgrade download --releasever=<target_version> --allowerasing

The --allowerasing option is a very important option for handling tricky changes in what packages need during big system updates. It lets DNF5 automatically remove or replace packages that cause problems and would stop the update.

While it makes for a smooth, automatic update, using it means users need to know what might happen, like some programs being removed. Check the changes carefully before typing yes.

4. Restart and Apply the Update:

sudo dnf5 system-upgrade reboot

It restarts your computer to put the downloaded update in place. Your system will start in a special mode to finish the update.

5. Check the Update:

To confirm that your system is running the newly updated Fedora version, run:

cat /etc/os-release

This command shows your current Fedora Linux version info.

Troubleshooting Common DNF5 Issues

Even though DNF5 is a powerful and modern package manager, problems can still happen. Knowing the common issues and how to fix them can help keep your system stable.

1. Fixing Package Conflicts During Upgrades

When you upgrade your system, you may see package conflicts.

These happen when some packages can't be installed together because of missing or clashing dependencies.

DNF5 offers a clear way to handle this: use the --allowerasing option during the system-upgrade download step. This tells DNF5 to remove or replace any conflicting packages so the upgrade can continue.

Please be careful though. This option can remove packages you may still need, even if you don’t use them often. Always review the list before confirming.

2. Reinstalling Problematic Applications

If an application doesn’t work right after an upgrade, maybe it crashes or won’t start, reinstalling it often solves the problem.

A reinstall makes sure all required files and dependencies are present and match the new system setup.

3. Why sudo dnf5 update --refresh Matters

Before making changes to your system, run:

sudo dnf5 update --refresh

This updates your package list and checks for the latest versions.

It’s not just for prep, it also fixes many small issues, like boot problems or missing security updates. Always run it before major upgrades.

4. Skipping Unavailable Packages

DNF5 adds a useful new option: --skip-unavailable. If you try to install or upgrade packages and one isn’t in any repo, this flag tells DNF5 to continue anyway.

That way, one missing package won’t stop the whole task. It gives you more control, especially when dealing with custom or third-party software.

5. What Happened to --skip-broken?

In DNF4, the --skip-broken option didn’t always work. DNF5 removes it completely. Instead, use --best to always choose the most up-to-date

This lets DNF5 automatically remove or swap programs that cause problems. Use this command if programs clash when downloading. packages, or --no-best for more flexibility.

These options are clearer and more reliable for managing dependencies.

6. General Fixes for Common Problems

If you’re still having trouble, here are two commands that can help:

sudo dnf5 clean all

This command clears cached data that might be outdated or broken.

sudo dnf5 distro-sync --refresh --allowerasing

It syncs your installed packages with what's in the repos. It fixes mismatches by reinstalling or downgrading as needed.

These commands can solve many issues related to broken updates, missing files, or software that stops working after changes.

Frequently Asked Questions (FAQs)

These common questions help new users understand DNF5 package manager.

Q: What is DNF5, and why is Fedora switching to it?

A: DNF5 is Fedora’s new package manager, starting in Fedora 41. It replaces DNF (also known as DNF4). The Fedora team rewrote DNF5 in C++ to make it faster and more efficient. It uses less memory and provides a cleaner, more consistent user experience.

Q: How is DNF5 different from DNF?

A: Most basic commands still work the same, but DNF5 has clearer rules. For example, it requires subcommands like history list instead of just history.

Some options have been renamed or removed. Others are new and give you more control. DNF5 also stores data in new locations and keeps a separate history from DNF4.

Q: Can I still use dnf or yum?

A: Yes. In Fedora 41 and later, dnf points to dnf5, so the command still works. A yum link is also available for older tools and scripts. But it's best to use dnf5 directly. That avoids confusion and helps you get the most out of the new features.

Q: What are DNF5 groups, and how do I use them?

A: Groups are sets of related packages that help you install full environments or tools—like "KDE Plasma Workspaces" or "Development Tools."

To see all groups, run dnf5 group list. To include hidden groups, add --hidden. To view details about a group, use dnf5 group info "<group-name>".

Q: How do I upgrade Fedora using DNF5?

A: First, make sure your system is fully updated. Then install the system upgrade plugin:

sudo dnf5 install dnf5-plugin-system-upgrade

Next, download the upgrade packages:

sudo dnf5 system-upgrade download --releasever=<target_version>

Finally, reboot into the upgrade process:

sudo dnf5 system-upgrade reboot

Q: What if I run into conflicts during an upgrade?

A: If DNF5 finds package conflicts, add the --allowerasing option during the download step. This lets DNF5 remove or replace packages that cause issues. If any apps act up after the upgrade, try reinstalling them.

Q: Where does DNF5 keep its cache?

A: User cache is stored in ~/.cache/libdnf5. For system tasks, DNF5 uses /var/cache/libdnf5. This new setup keeps things organized and easier to manage.

Conclusion

In this detailed guide, we explained how to use DNF5 package manager for managing packages in Fedora and RHEL systems. By understanding and utilizing the common DNF5 commands, users can manage their software packages more effectively.

Keep this guide handy as a reference. Use it to get comfortable with the new DNF5 commands, fix common issues, and make the most of Fedora’s improved package manager.

Resource:

Recommended Read:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More