DNF (Dandified YUM) — Package Management in RHEL, Rocky, AlmaLinux, and Fedora¶
DNF (Dandified YUM) is the modern package manager used by Fedora, Red Hat Enterprise Linux (RHEL), Rocky Linux, AlmaLinux, and other RPM-based distributions. It simplifies installing, updating, removing, and managing software packages while providing better dependency resolution, improved performance, and enhanced security compared to its predecessor, YUM.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand DNF
- Install and remove software packages
- Search package repositories
- Update installed software
- Manage dependencies
- View package information
- Clean package cache
- Apply package management in production
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management and Permissions
- Module 5 – Users and Groups
- Module 6 – Process Management
- Module 7 Lesson 1 – APT
Why Learn DNF?¶
Imagine you're managing:
- Red Hat Enterprise Linux servers
- Rocky Linux production systems
- AlmaLinux cloud instances
- Fedora developer workstations
You need to:
- Install Docker
- Update Kubernetes tools
- Patch security vulnerabilities
- Remove unused software
DNF makes these tasks simple and reliable.
What is DNF?¶
DNF stands for:
Dandified YUM
It is the default package manager for modern RPM-based Linux distributions.
DNF works with:
packages and automatically:
- Resolves dependencies
- Downloads packages
- Verifies package signatures
- Installs software
- Manages updates
Package Management Workflow¶
DNF Command
│
▼
Software Repository
│
▼
Download Packages
│
▼
Resolve Dependencies
│
▼
Install Software
│
▼
Ready to Use
What is an RPM Package?¶
An RPM package contains:
- Executable binaries
- Libraries
- Configuration files
- Documentation
- Metadata
Example:
Refresh Repository Metadata¶
Before installing packages:
This checks repositories for available updates and refreshes package metadata if needed.
Install a Package¶
Example:
Install multiple packages.
DNF automatically resolves dependencies.
Upgrade Installed Packages¶
Upgrade all installed packages.
or
Both commands are equivalent in modern DNF.
Upgrade a Specific Package¶
Remove a Package¶
Unused dependencies are removed when appropriate.
Search for Packages¶
Example:
View Package Information¶
Displays:
- Version
- Repository
- Size
- Description
- Architecture
List Installed Packages¶
Search for a package.
Check Available Updates¶
Displays packages that have newer versions available.
Display Package Repositories¶
Example:
Clean Package Cache¶
Remove cached packages.
Remove all cached metadata and packages.
Rebuild the cache.
Download a Package Without Installing¶
Note
The dnf download command is provided by the dnf-plugins-core package on many distributions.
View Package History¶
Display transaction history.
Example:
View details of a transaction.
Undo a Transaction¶
This attempts to reverse a previous package transaction.
Common Commands¶
Install package.
Upgrade packages.
Remove package.
Search package.
Display package information.
List repositories.
Real Production Examples¶
Install Git.
Install Docker.
Update production server.
Install Kubernetes CLI.
Production Perspective¶
DNF is widely used for:
- Red Hat Enterprise Linux
- Rocky Linux
- AlmaLinux
- Fedora
- Cloud Virtual Machines
- Kubernetes Nodes
- Enterprise Servers
- Production Infrastructure
Keeping packages updated is essential for security and stability.
Hands-on Lab¶
Task 1¶
List enabled repositories.
Task 2¶
Search for Git.
Task 3¶
View package details.
Task 4¶
Check for updates.
Task 5¶
Install Git (if not already installed).
Task 6¶
Verify installation.
Task 7¶
View package history.
Task 8¶
Clean the package cache.
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
dnf install | Install packages | Software deployment |
dnf upgrade | Upgrade installed packages | Security patching |
dnf remove | Remove software | Cleanup |
dnf search | Search repositories | Package discovery |
dnf info | Display package information | Verification |
dnf repolist | List repositories | Repository management |
dnf history | View transaction history | Auditing |
dnf clean all | Clear cache | Maintenance |
DNF vs APT¶
| Feature | APT | DNF |
|---|---|---|
| Package Format | .deb | .rpm |
| Primary Distributions | Debian, Ubuntu | RHEL, Rocky, AlmaLinux, Fedora |
| Install | apt install | dnf install |
| Update Metadata | apt update | dnf check-update / dnf makecache |
| Upgrade | apt upgrade | dnf upgrade |
| Package Info | apt show | dnf info |
Production Troubleshooting Scenario¶
Scenario
A system administrator attempts to install NGINX.
Error:
Investigation:
The required repository is disabled.
After enabling the correct repository:
The package installs successfully.
Best Practices¶
- Keep repositories enabled and synchronized.
- Apply security updates regularly.
- Review package changes before upgrading production systems.
- Remove unused software.
- Clean the package cache periodically.
- Use only trusted repositories.
Common Mistakes¶
❌ Installing packages from untrusted repositories.
✅ Avoid this mistake: installing packages from untrusted repositories.
❌ Ignoring available security updates.
✅ Always review available security updates.
❌ Cleaning metadata without rebuilding the cache when required.
✅ Avoid this mistake: cleaning metadata without rebuilding the cache when required.
❌ Upgrading production servers without testing critical applications.
✅ Avoid this mistake: upgrading production servers without testing critical applications.
Interview Questions¶
Beginner¶
- What does DNF stand for?
- Which Linux distributions use DNF?
- Which command installs a package?
- How do you search for a package?
Intermediate¶
- What is the difference between
dnf upgradeanddnf check-update? - How do you list enabled repositories?
- How do you remove a package?
- What is the purpose of
dnf history?
Architect Level¶
- How would you manage package updates across hundreds of RHEL servers?
- Why should production systems use trusted repositories?
- How would you implement a package update strategy that minimizes downtime?
Summary¶
In this lesson, you learned:
- DNF package management
- Package installation
- Package upgrades
- Repository management
- Package history
- Package cleanup
- Production best practices
DNF is the modern package manager for RPM-based Linux distributions. It simplifies software management by automatically resolving dependencies, managing repositories, and tracking package transactions. Mastering DNF is essential for administering Red Hat Enterprise Linux, Rocky Linux, AlmaLinux, and Fedora systems.
Key Takeaways¶
- DNF is the default package manager for modern RPM-based distributions.
- Use
dnf installto install software. - Use
dnf upgradeto apply updates. - Use
dnf searchanddnf infoto explore packages. - Use
dnf historyto review package transactions. - Use trusted repositories and apply updates regularly.
What's Next?¶
YUM (Yellowdog Updater Modified) — Package Management for Legacy RHEL Systems
You'll explore:
- What YUM is
- How YUM differs from DNF
- Installing and updating packages
- Repository management
- Legacy RHEL systems
- Migration from YUM to DNF
- Production package management for older enterprise Linux systems