The dnf command in Linux: modern package manager in Fedora

Introduction

In the Linux ecosystem, package management is a fundamental task for keeping the system up to date and secure. In Fedora, the dnf command has replaced the old yum as the default manager, offering a faster, more reliable, and secure experience for users and administrators.

What is DNF?

DNF, short for Dandified YUM, is the next-generation package manager developed by Red Hat. It uses an architecture based on libsolv for dependency resolution, allowing faster calculations and lower resource consumption compared to its predecessor.

Advantages over YUM

Among the most notable improvements are superior performance in dependency resolution, better conflict handling, native support for modules and groups, and a more consistent command-line interface. Additionally, DNF includes security enhancements, such as GPG signature verification by default.

Basic Installation and Configuration

In a standard Fedora installation, DNF comes preinstalled. If for some reason it is missing, it can be installed with the command sudo dnf install dnf. The main configuration file is located at /etc/dnf/dnf.conf, where options such as the maximum number of parallel downloads or the repository location can be adjusted.

Common Operations: Search and Installation

To search for a package, use dnf search keyword. Installation is performed with sudo dnf install package_name. DNF automatically resolves dependencies and shows a summary before proceeding, allowing the user to confirm or cancel the operation.

Updating and Removing Packages

Updating the entire system is as simple as running sudo dnf upgrade. To update a specific package, specify its name after the command. Removal is done with sudo dnf remove package_name, and DNF also removes dependencies that are no longer needed if the --autoremove parameter is specified.

Managing Groups and Modules

DNF allows working with package groups via dnf group list, dnf group install group_name and dnf group remove group_name. Modules, introduced in Fedora Modularity, allow installing different versions of the same application; they are managed with dnf module list, dnf module install module_name:version and dnf module remove module_name.

History and Transactions

Each operation performed with DNF is recorded in its history. The command dnf history displays a list of transactions, and with dnf history info ID you can view the details of a specific transaction. It is possible to undo or redo a transaction using dnf history undo ID or dnf history redo ID.

Troubleshooting Common Issues

If dependency errors occur, you can try cleaning the cache with sudo dnf clean all and then re-running the operation. In case of file conflicts, DNF usually offers options to replace or keep the current file. Detailed logs are located in /var/log/dnf.log and are useful for debugging installation or upgrade failures.

Best Practices and Tips

It is recommended to run dnf upgrade --refresh periodically to ensure that repository metadata is up to date. Using the --assumeno flag allows simulating operations without making changes, useful for reviewing which packages would be affected. Finally, keeping the system backed up before performing major updates helps mitigate unexpected risks.

Conclusion

DNF represents a significant advancement in package management for Fedora and other RPM-based distributions. Its speed, reliability, and feature set make it an essential tool for both everyday users and system administrators. Mastering its use allows maintaining an up-to-date, secure, and efficient Linux environment.

This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .