‘DNF’ (Fork of Yum) Commands for RPM Package Management in Linux

DNF (Dandified Yum) is a modern package manager for RPM-based Linux distributions and serves as the successor to Yum. Introduced in Fedora 18, DNF offers significant improvements including faster performance, better memory usage, and a cleaner codebase. This article explores essential DNF commands for RPM package management in Linux distributions like Fedora, CentOS 8+, and Red Hat Enterprise Linux 8+.

Basic DNF Commands

DNF provides essential commands for everyday package management tasks. These commands automatically handle dependency resolution, making package installation and removal much simpler than using RPM directly.

Installing Packages

To install a package and its dependencies:

sudo dnf install package_name

Install multiple packages at once:

sudo dnf install package1 package2 package3

Updating Packages

Update all installed packages to their latest versions:

sudo dnf update

Update a specific package:

sudo dnf update package_name

Removing Packages

Remove a package and its unused dependencies:

sudo dnf remove package_name

Searching for Packages

Search for packages in available repositories:

dnf search package_name

Get detailed information about a package:

dnf info package_name

Advanced DNF Commands

Advanced DNF commands provide granular control over package management and repository operations.

Repository Management

List enabled repositories:

dnf repolist

Query packages in repositories:

dnf repoquery package_name

Check for available updates:

dnf check-update

Package History and Transactions

View transaction history:

dnf history

Undo the last transaction:

sudo dnf history undo last

Managing Repositories

DNF simplifies repository management with built-in commands and secure GPG key verification.

Adding Repositories

Add a repository using its URL:

sudo dnf config-manager --add-repo repository_url

Manually create a repository file in /etc/yum.repos.d/:

[repository-name]
name=Repository Display Name
baseurl=https://example.com/repo/path/$basearch
enabled=1
gpgcheck=1
gpgkey=https://example.com/gpg-key.pub

Disabling Repositories

Temporarily disable a repository:

sudo dnf config-manager --disable repository_id

Enable a disabled repository:

sudo dnf config-manager --enable repository_id

System Upgrades

DNF distinguishes between updates and upgrades. Updates install newer versions of existing packages, while upgrades can install new packages and remove obsolete ones.

Package Upgrades

Upgrade all packages, including kernel updates:

sudo dnf upgrade

System Distribution Upgrades

For major system version upgrades, use the system-upgrade plugin:

sudo dnf system-upgrade download --releasever=35
sudo dnf system-upgrade reboot

Troubleshooting DNF

Common DNF issues can often be resolved with these troubleshooting steps:

Cache Management

Clean all cached data:

sudo dnf clean all

Rebuild the cache:

sudo dnf makecache

Dependency Issues

Fix broken dependencies:

sudo dnf autoremove

Log Analysis

Check DNF logs for detailed error information:

sudo tail -f /var/log/dnf.log
sudo tail -f /var/log/dnf.rpm.log

DNF vs Yum Comparison

Feature DNF Yum
Memory Usage Lower Higher
Dependency Resolution SAT solver (faster) Traditional resolver
Python Version Python 3 Python 2
API Documented, stable Limited documentation
Performance Faster Slower

Conclusion

DNF represents a significant improvement over Yum with faster performance, better dependency resolution, and modern architecture. Its automatic dependency handling, secure GPG verification, and comprehensive command set make it an excellent choice for RPM-based package management. Regular use of DNF commands ensures your Linux system remains updated and secure.

Updated on: 2026-03-17T09:01:38+05:30

488 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements