DNF, or Dandified YUM, is a modern package manager used in RPM-based Linux distributions. It’s a successor to the traditional YUM (Yellowdog Updater Modified) package manager, offering improved performance, dependency resolution, and additional features. In this comprehensive guide, we’ll dive into various use cases of the DNF command.
1. Installing Packages with DNF
To install a package using DNF, you can use the following command:
# sudo dnf install package-name
For example, to install the “htop” package (a popular system monitoring tool), you’d use:
# sudo dnf install htop
You can also install multiple packages at once by listing them all on the command line. This is useful when you want to install several packages in a single command:
# sudo dnf install package1 package2 package3
To install a package using a specific repository, you can use the following command:
# sudo dnf install --enablerepo=<repository-name> <package-name>
For example, to install the “htop” package (a popular system monitoring tool), from epel repo you’d use:
# sudo dnf install --enablerepo=epel htop OR # sudo dnf install --disablerepo=* --enablerepo=epel htop
2. Updating Packages with DNF
Keeping your system up to date is essential for security and performance. To update all installed packages to their latest versions, use the following command:
# sudo dnf update
To update a specific package, you can specify its name:
# sudo dnf update package-name
For example, to update the “htop” package, use:
# sudo dnf update htop
If you want to update your entire system, including the Linux kernel, you can use the following command:
# sudo dnf update --refresh
3. Searching for Packages with DNF
DNF allows you to search for available packages using the following command:
# dnf search keyword
For instance, to search for packages related to “python,” you can use:
# dnf search python
You can narrow down the search by using more specific keywords. Additionally, you can use wildcards to match patterns in package names or descriptions. This is useful when you’re not sure of the exact package name:
# dnf search *keyword*
For example, to search for packages related to text editors, you can use:
# dnf search *editor*
4. Removing Packages with DNF
To remove a package from your system, use the following command:
# sudo dnf remove package-name
For example, to remove the “htop” package, you can use:
# sudo dnf remove htop
You can also remove multiple packages at once:
# sudo dnf remove package1 package2 package3
5. Listing Installed Packages With DNF
To list all installed packages on your system, you can use the following command:
# dnf list installed
To list a specific installed package on your system, you can use the following command:
# dnf list installed httpd Installed Packages httpd.x86_64 2.4.53-11.el9_2.5 @appstream
This command will display a comprehensive list of all packages that are currently installed. It’s helpful for getting an overview of the software installed on your system.
6. Managing Repositories With DNF
DNF manages repositories, which are collections of software packages. By default, DNF uses the system repositories, but you can add, enable, disable, or remove repositories as needed. To list the currently enabled repositories, use the following command:
# sudo dnf repolist
To list the all enabled and disabled repositories, use the following command:
# sudo dnf repolist all
To enable a repository, you can use:
# sudo dnf config-manager --set-enabled repository-name
To disable a repository, use:
# sudo dnf config-manager --set-disabled repository-name
To add a new repository, you’ll need the repository file with the .repo extension. You can place this file in the /etc/yum.repos.d/
directory. After adding the repository, you can enable it using the previous command.
7. Removing Packages with DNF
To remove a package using DNF, you can use the following command:
# dnf erase package-name
For example, to remove the “firefox” package, use:
# dnf erase firefox
8. Automatic Package Removal
DNF can also remove packages that are no longer required as dependencies. To perform this cleanup, use:
# dnf autoremove
9. Finding Package Providing a File
To find which package provides a specific file, you can use:
# dnf provides file-name
For instance, to find which package provides the “ls” command, use:
# dnf provides /bin/ls
10. Viewing Transaction History
DNF keeps track of package transactions. To list the recent transaction history, use:
# dnf history list
To view details of a specific transaction, use its ID with the following command:
# dnf history info <transaction-id>
To undo a specific transaction, use its ID with the following command:
# dnf history undo <transaction-id>
11. Checking for Available Updates
To check for updates without performing them, use:
# dnf check-update
12. Managing Software Groups with DNF
DNF also supports managing software groups on RPM-based systems. To list available groups, use:
# dnf grouplist
To install a software group, use:
# dnf groupinstall 'Group Name'
To view information about a specific group, use:
# dnf groupinfo 'Group Name'
To remove a software group, use:
# dnf groupremove 'Group Name'
Conclusion
DNF is a powerful package manager that simplifies software management on RPM-based Linux distributions. Its straightforward commands for installation, updating, searching, and removal of packages, along with the ability to manage repositories, make it a valuable tool for system administrators and Linux users. By mastering these DNF commands and understanding its capabilities, you can efficiently manage software on your Linux system and keep it up to date.
==================================================================================
Was this article of use to you? Post your insightful thoughts or recommendations in the comments section if you don’t find this article to be helpful or if you see any outdated information, a problem, or a typo to help this article better.
==================================================================================