Table of Contents#
- What is dnf5?
- Installing dnf5
- Basic dnf5 Commands
- System Maintenance with dnf5
- Advanced dnf5 Usage
- Key Differences from Classic DNF
- Conclusion
- 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 update2. Install the dnf5 package:
sudo dnf install dnf5Once 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
dnfuntil 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 neofetchThis will list all packages whose name or description contains "neofetch".
List all available packages (can be a very long list):
dnf5 list availableList all installed packages:
dnf5 list installedInstalling 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 neofetchInstall multiple packages at once:
sudo dnf5 install htop vim gitRemoving Packages#
To remove an installed package, use the remove command.
Remove a package:
sudo dnf5 remove neofetchThis 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 neofetchThe 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-updateThis lists all packages that have updates available without performing the update.
Update a specific package:
sudo dnf5 update firefoxUpdate all packages on the system:
sudo dnf5 updateThis 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-cacheThis is the dnf5 equivalent of sudo dnf makecache.
List all enabled repositories:
dnf5 repolistSystem 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 packagesRemove all cached metadata and package files (a more thorough cleanup):
sudo dnf5 clean allRemove 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 autoremoveAdvanced 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 listInstall 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 firefoxThis displays the version, release, size, description, and URL for the package.
List the files contained in an installed package:
dnf5 repoquery -l firefoxInvestigating Dependencies#
Understanding package relationships is key for troubleshooting.
List a package's dependencies (what it requires):
dnf5 repoquery --requires firefoxFind which package provides a specific file or dependency:
dnf5 provides /bin/lsThis 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 historyUndo a specific transaction (by its ID):
sudo dnf5 history undo 23This 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:
- Command Aliases: Some command aliases are different. For example, the old
dnf repoquerycommand's functionality is now integrated directly intodnf5(as seen withdnf5 repoquery), but some subcommands might differ. - 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.conffor low-level settings. - Plugins: The plugin system is different. Plugins written for classic DNF are not compatible with dnf5 and need to be ported.
- Output Format: The output of some commands is cleaner and more condensed.
- Strict Aliasing: dnf5 is stricter about package naming. You can no longer use the
-yflag 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#
- Fedora Wiki: DNF5 - The official project page for dnf5 on the Fedora Wiki.
- dnf5 GitHub Repository - The source code and issue tracker for dnf5.
- Man Page: dnf5 - Official documentation for the dnf5 command (man dnf5).
- Fedora Magazine: Trying DNF5 - Articles and tutorials from Fedora Magazine.