DNF (Dandified YUM) can be considered as the updated version of YUM utility. DNF utility stands far better than other package managers when it comes to memory usage, CPU utilization, and various other performance-related factors.
In this tutorial, we learn how to use the DNF package management tool to install packages with examples.
Install packages
Before you start installing packages, it's prudent to search and verify whether the package is available. We do this by using the search option:
dnf search package-name
In this example, we search whether the httpd package is available for installation.
dnf search httpd
Sample Output
Last metadata expiration check: 0:01:02 ago on Tue 02 Aug 2022 02:48:01 AM UTC.
================== Name Exactly Matched: httpd ======================
httpd.x86_64 : Apache HTTP Server
==========Name & Summary Matched: httpd ===========================
anyterm-httpd.x86_64 : Httpd proxy configuration for anyterm
dmlite-apache-httpd.i686 : Apache HTTPD frontend for dmlite
dmlite-apache-httpd.x86_64 : Apache HTTPD frontend for dmlite
fedora-logos-httpd.noarch : Fedora-related icons and pictures used by httpd
gambas3-gb-httpd.x86_64 : Gambas3 component package for httpd
generic-logos-httpd.noarch : Fedora-related icons and pictures used by httpd
httpd-core.i686 : httpd minimal core
httpd-core.x86_64 : httpd minimal core
In the above output, you get all the possibilities of the package httpd highlighted.
To install a package, log in as root or sudo user and run the command below. In this example, we are installing Apache web server.
sudo dnf install httpd
Before proceeding to install it shows package and its dependencies name, architecture, version, repository, and size. If you wish to proceed Press Y to install the package.
When a specific version of the package is given, DNF will install the desired version. The former version of the package will be removed. To install a specific version:
dnf install package-0.5.6-1.fc36
Install a local rpm file:
dnf install ~/Downloads/package-0.5.6-1.fc36.noarch.rpm
To install from a given URL:
dnf install <url-path>
Install packages from a specific repository
With DNF command we can also choose a specific repository for a package installation. Let's first see the available repositories installed in our Fedora 36 system by running the command below.
dnf repolist
Output
repo id repo name
fedora Fedora 36 - x86_64 fedora-cisco-openh264 Fedora 36 openh264 (From Cisco) - x86_64 fedora-modular Fedora Modular 36 - x86_64 updates Fedora 36 - x86_64 - Updates updates-modular Fedora Modular 36 - x86_64 - Updates
Let's now install a package called nano from *fedora repository.
sudo dnf --enablerepo=fedora install nano
Verify installed packages
To verify the installed packages and their version, use dnf list installed command.
For example, to check httpd package is installed or not:
dnf list installed http*
Installed Packages
httpd.x86_64 2.4.54-3.fc36 @updates
httpd-core.x86_64 2.4.54-3.fc36 @updates
httpd-filesystem.noarch 2.4.54-3.fc36 @updates
httpd-tools.x86_64 2.4.54-3.fc36 @updates
Conclusion
In this tutorial, we learned how to install packages using DNF. Similarly, you can uninstall packages very easily.
Thanks for reading, please provide your feedback and suggestions in the below comment section.
Comments