- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
‘DNF’ (Fork of Yum) Commands for RPM Package Management in Linux
Introduction
DNF is a package manager for RPM-based Linux distributions and it is a successor to Yum, another package manager. DNF stands for Dandified Yum and it was introduced in Fedora 18 as a replacement for Yum. The key benefits of using DNF over Yum are faster performance, better memory usage, and a more modern codebase. In this article, we will explore DNF commands for RPM package management in Linux. We will cover basic DNF commands, advanced DNF commands, managing repositories with DNF, updating and upgrading packages with DNF, and troubleshooting DNF.
Basic DNF Commands
DNF provides several basic commands for package management, including −
Install − This command installs a package and its dependencies. To install a package, use the command −
$ sudo dnf install package_name
Update − This command updates all installed packages to their latest available versions. To update all installed packages, use the command −
$ sudo dnf update
Remove − This command removes a package and its dependencies. To remove a package, use the command −
$ sudo dnf remove package_name
Search − This command searches for packages in the available repositories. To search for a package, use the command −
$ sudo dnf search package_name
Benefits of using DNF commands instead of RPM commands directly −
DNF commands automatically resolve dependencies, making it easier to install and manage packages.
DNF commands provide more user-friendly output and progress indicators.
DNF commands are more secure because they use GPG keys to verify packages.
Advanced DNF Commands
DNF also provides several advanced commands for package management, including −
Repoquery − This command queries packages in the repositories. To query a package, use the command −
dnf repoquery package_name
Repolist − This command lists the enabled repositories. To list the enabled repositories, use the command −
dnf repolist
Check-update − This command checks for updates in the repositories. To check for updates, use the command −
dnf check-update
Advanced DNF commands provide more granular control over package management. These enable you to query package information and manage repositories more effectively.
Managing Repositories with DNF
DNF enables you to manage repositories more easily by providing commands to add and remove repositories. Managing repositories with DNF is more secure because it verifies GPG keys. DNF enables you to manage repositories more easily and efficiently.
To add a repository, use the command −
$ dnf config-manager --add-repo repository_url
To remove a repository, use the command −
$ dnf config-manager --disable repository_id
Adding a Repository
To add a new repository, you need to create a new .repo file in the “/etc/yum.repos.d/” directory. For example, to add the 'Google Chrome' repository,
[google-chrome] name=google-chrome baseurl=https://dl.google.com/linux/chrome/rpm/stable/$basearch enabled=1 gpgcheck=1 gpgkey=https://dl.google.com/linux/linux_signing_key.pub
Updating and Upgrading Packages with DNF
DNF provides commands to update and upgrade packages on your system. Here are the commands you can use −
Upgrade − This command upgrades all installed packages to their latest available versions, including kernel and system updates. To upgrade all installed packages, use the command −
$ sudo dnf upgrade
Dist Upgrade − This command upgrades your entire system to the latest release. To upgrade your system to the latest release, use the command −
$ sudo dnf system-upgrade
This command upgrades your entire system to the latest release. It's important to note that this command can take a while to complete, so make sure you have enough time set aside before starting.
Troubleshooting DNF
If you encounter issues while using DNF, there are a few troubleshooting steps you can take −
Check your internet connection − DNF requires an active internet connection to download packages from repositories. Make sure your internet connection is working properly.
Clean the cache − DNF stores downloaded packages in a cache. If the cache becomes corrupted, it can cause issues. To clean the cache, use the command −
$ sudo dnf clean all
Check the log files − DNF logs all activities to log files. You can check the log files to identify issues. The log files are located in “/var/log/dnf.log” and “/var/log/dnf.rpm.log”.
Conclusion
Overall, DNF is a powerful package manager for RPM-based Linux distributions that provides several commands for package management, including basic and advanced commands. Managing repositories with DNF is more secure and efficient than other methods. Updating and upgrading packages with DNF is straightforward and easy. If you encounter issues while using DNF, there are troubleshooting steps you can take to resolve them. With DNF, managing packages on your Linux system is easier and more efficient than ever.