If you’re using a modern Red Hat-based system like Fedora 43, CentOS Stream, or RHEL, you will inevitably interact with DNF. While the Software Center (GUI) is great for browsing, the terminal is where the real power lies. Understanding how to use DNF package manager is the single most important skill for managing your system effectively.
DNF, which stands for “Dandified YUM,” is the modern, robust package manager that handles installing, updating, and removing software on your Linux system.
This guide is designed to make you comfortable and confident with the latest commands. We’ll start with the absolute basics and move on to some powerful tricks that will make you feel like a pro.
You Are Using DNF5: What You Need to Know
If you are using Fedora 41 or newer (including our current Fedora 43), you are using DNF5 by default. This is important to know.
- The YUM -> DNF4 -> DNF5 History: DNF (also known as DNF4) replaced the older YUM years ago. Now, DNF5 has superseded DNF4, bringing massive improvements in speed and management.
- The Command is the Same: On your system, the
dnfcommand is now simply a symbolic link (symlink) todnf5. So, when you typednf, you are actually running DNF5. - Command Compatibility: The good news is that all the basic commands you know (like
install,remove,search) are identical. Only a few advanced commands have changed, which we will highlight in this guide. - Critical Warning: DNF4 and DNF5 do not share transaction histories. If you just upgraded from an older system, DNF5 will not see the DNF4 history. For clean installs of Fedora 43, this is not an issue.
The Basic DNF Command Syntax
The first thing to know is that almost every DNF command that makes changes to your system requires administrative privileges. This means you must preface your commands with sudo.
The basic syntax looks like this:
sudo dnf [options] [command] [package_name]
This structure will become second nature very quickly. Let’s break down the most useful commands.
How to Manage Packages with DNF: The Daily Essentials
This section covers the commands you will use 90% of the time. This is the core of how to manage packages with DNF.
1. Updating Your System
This is the most crucial task you should perform regularly. Keeping your system updated patches security vulnerabilities and provides you with the latest features.
First, you can check what updates are available:
sudo dnf check-update
This command is safe and will only list the packages that have a new version available.
To actually download and apply the updates, run the upgrade command. It’s good practice to add the --refresh flag to ensure DNF fetches the latest list of packages from the repositories first.
sudo dnf upgrade --refresh
DNF will show you a list of everything it’s about to do and ask for confirmation. Just press y and Enter to proceed.
2. Searching for a Package
You want to install a program, but you’re not sure of its exact name. The search command is your best friend.
dnf search [keyword]
For example, if you’re looking for the GIMP image editor:
dnf search gimp
DNF will search its database and return a list of packages that match your keyword in their name or description. You’ll see something like gimp.x86_64, which tells you the exact package name you need.
3. Getting Information About a Package
Before you install something, you might want to know more about it. The info command provides a detailed description, version, release, and which repository it comes from.
dnf info [package_name]
Using our GIMP example:
dnf info gimp
This is perfect for verifying you have the right package.
4. Installing a Package
Once you know the package name, installing it is simple:
sudo dnf install [package_name]
Let’s install GIMP:
sudo dnf install gimp
DNF will automatically calculate all the dependencies (other packages that GIMP needs to run) and ask for your permission to install them all.
If you are 100% sure you want to proceed and want to skip the [y/N] prompt, you can add the -y flag:
sudo dnf install gimp -y
5. Removing a Package
If you no longer need a program, you can remove it just as easily:
sudo dnf remove [package_name]
To remove GIMP:
sudo dnf remove gimp
DNF will show you the package(s) it’s about to remove and ask for confirmation.
Warning: Removing Packages and Dependencies
When you run sudo dnf remove [package], DNF removes that specific package. However, it might leave behind dependencies that were installed only for that package and are now no longer needed. To clean these up, you should run the autoremove command.
6. Cleaning Up Orphaned Dependencies
This is the command you should run after removing software to keep your system clean. autoremove finds and removes packages that were installed as dependencies but are no longer required by any installed program.
sudo dnf autoremove
This is a safe and highly recommended command to run periodically.
Advanced DNF Command Examples
Ready to level up? These dnf command examples solve common problems and showcase DNF5’s true power.
7. Finding Which Package Provides a File
Have you ever seen an error message about a missing file (like libsomething.so.2)? Or wondered which package installed a specific command (like /usr/bin/ssh)? The provides command is your solution.
dnf provides [path/to/file]
Example:
dnf provides /usr/bin/htop
DNF will search the repositories and tell you, “htop-3.3.0-1.fc43.x86_64 : Interactive process viewer,” so you know the htop package is what you need to install.
8. Managing Package Groups
Sometimes, you want to install a whole set of tools for a specific purpose, like “Development Tools” or a full desktop environment like “KDE Plasma Workspaces.” DNF uses “groups” for this.
First, you can list all available groups:
dnf group list
DNF5 Change: The command to install a group is now group install (two words).
sudo dnf group install "Development Tools"
(Note: Use quotes if the group name has spaces.)
Similarly, the command to remove a group is group remove:
sudo dnf group remove "Development Tools"
9. Viewing DNF History
This is one of DNF’s best features. DNF logs every single transaction (install, remove, upgrade) you perform.
DNF5 Change: To see the log, you must now run history list:
dnf history list
You will see a list with an ID number for each transaction. This is more than just a log; it’s an “undo” button.
10. The Ultimate “Undo”: Rolling Back Transactions
Did that last update break something? Did you accidentally remove a package you needed? You can use the history log to reverse a transaction.
First, run dnf history list to find the ID of the transaction you want to undo. Let’s say it was ID 42.
To roll back that action, you run (this command remains the same):
sudo dnf history undo 42
DNF will calculate what’s needed to revert your system to the state it was in before transaction #42 occurred. This is an absolute lifesaver.
DNF vs. Flatpak: A Quick Note
As a modern Fedora user, you’ll see both DNF and Flatpak. It’s important to know the difference.
- DNF manages system-level packages (RPMs) from the official FEDORA PROJECT repositories. These are integrated deeply into your OS.
- Flatpak manages sandboxed, containerized applications that run in isolation from your main system. These often come from FLATHUB and are great for desktop apps.
You will use both! Use DNF for system libraries, command-line tools, and core components. Use Flatpak for desktop applications like Spotify, Slack, or Steam.
Conclusion: You Are Now in Control
You’ve just learned how to use DNF package manager (specifically DNF5). You know how to find, install, update, and remove software. More importantly, you know how to clean up your system with autoremove, find files with provides, and even travel back in time with dnf history undo.
DNF5 is a powerful, reliable tool, and by mastering these commands, you have taken a massive step toward becoming a confident Linux power user.
What are your favorite DNF commands or tips? Did the history undo command ever save you from a major headache? Share your experiences and questions in the comments below!

