
DNF
Dandified YUM or DNF is the name of the package management utility. DNF is the next-generation version of YUM. It's used in RPM-based distributions. DNF was introduced in Fedora 18, and has been the default package manager for Fedora since version 22. In fact, when we run YUM commands in later releases of Fedora, we are actually running dnf in the background. The dnf utility offers, among other things, performance, memory usages, and dependency resolution.
To get started, we can check the version of dnf on our Fedora 28 system by using the --version option:
[root@localhost philip]# dnf --version
2.7.5
Installed: dnf-0:2.7.5-12.fc28.noarch at Wed 25 Apr 2018 06:35:34 AM GMT
Built : Fedora Project at Wed 18 Apr 2018 02:29:51 PM GMT
Installed: rpm-0:4.14.1-7.fc28.x86_64 at Wed 25 Apr 2018 06:34:14 AM GMT
Built : Fedora Project at Mon 19 Feb 2018 09:29:01 AM GMT
[root@localhost philip]#
Based on the preceding output, we have version 2.7.5 of the dnf utility installed. We can even view the repositories on our system by passing the repolist option:
[root@localhost philip]# dnf repolist
Last metadata expiration check: 0:01:09 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
repo id repo name status
*fedora Fedora 28 - x86_64 57,327
*updates Fedora 28 - x86_64 - Updates 16,337
[root@localhost philip]#
In addition to this, we can even expose the YUM command in Fedora 28 to prove that it is an alias to the dnf utility. We can do a listing of /usr/bin and search for YUM as follows:
[root@localhost philip]# ll /usr/bin | grep yum
lrwxrwxrwx. 1 root root 5 Apr 18 10:29 yum -> dnf-3
[root@localhost philip]#
Based on the preceding output, YUM is an alias inside the Fedora 28 system. We can also check to see whether repositories are enabled or not. For this, we use the repolist all option:
[root@localhost philip]# dnf repolist all
Once we run the preceding command, we get the following output:
Now, to view all the available packages on our system, we use the list option:
[root@localhost philip]# dnf list
Last metadata expiration check: 0:06:37 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
Installed Packages
GConf2.x86_64 3.2.6-20.fc28 @anaconda
GeoIP.x86_64 1.6.12-3.fc28 @anaconda
GeoIP-GeoLite-data.noarch 2018.04-1.fc28 @anaconda
ImageMagick.x86_64 1:6.9.9.38-1.fc28 @anaconda
ImageMagick-libs.x86_64 1:6.9.9.38-1.fc28 @anaconda
LibRaw.x86_64 0.18.8-1.fc28 @anaconda
ModemManager.x86_64 1.6.12-3.fc28 @anaconda
ModemManager-glib.x86_64 1.6.12-3.fc28 @anaconda
NetworkManager.x86_64 1:1.10.6-1.fc28 @anaconda
NetworkManager-adsl.x86_64 1:1.10.6-1.fc28 @anaconda
NetworkManager-bluetooth.x86_64 1:1.10.6-1.fc28 @anaconda
NetworkManager-config-connectivity-fedora.noarch 1:1.10.6-1.fc28 @anaconda
NetworkManager-libnm.x86_64 1:1.10.6-1.fc28 @anaconda
NetworkManager-openconnect.x86_64 1.2.4-9.fc28 @anaconda
NetworkManager-openconnect-gnome.x86_64 1.2.4-9.fc28 @anaconda
zziplib-utils.x86_64 0.13.68-1.fc28 fedora
zzuf.x86_64 0.15-5.fc28 fedora
[root@localhost philip]#
We can perform searches similar to YUM. For this, we use the search option:
[root@localhost philip]# dnf search firefox
Last metadata expiration check: 0:11:22 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
============================================ Summary & Name Matched: firefox =============================================
firefox.x86_64 : Mozilla Firefox Web browser
================================================ Summary Matched: firefox ================================================
icecat.x86_64 : GNU version of Firefox browser
mozilla-ublock-origin.noarch : An efficient blocker for Firefox
mozilla-https-everywhere.noarch : HTTPS enforcement extension for Mozilla Firefox
mozilla-requestpolicy.noarch : Firefox and Seamonkey extension that gives you control over cross-site requests
python-mozrunner.noarch : Reliable start/stop/configuration of Mozilla Applications (Firefox, Thunderbird)
[root@localhost philip]#
Awesome! Furthermore, to view which package provides a particular utility, we use the provides option:
[root@localhost philip]# dnf provides /bin/ksh
Last metadata expiration check: 0:14:22 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
ksh-20120801-247.fc28.x86_64 : The Original ATT Korn Shell
Repo : updates
Matched from:
Provide : /bin/ksh
ksh-20120801-245.fc28.x86_64 : The Original ATT Korn Shell
Repo : fedora
Matched from:
Provide : /bin/ksh
[root@localhost philip]#
In addition to this, we can view information for a specific package using the info option:
root@localhost philip]# dnf info libreoffice
Available Packages
Name : libreoffice
Epoch : 1
Version : 6.0.6.1
Summary : Free Software Productivity Suite
URL : http://www.libreoffice.org/
License : (MPLv1.1 or LGPLv3+) and LGPLv3 and LGPLv2+ and BSD and (MPLv1.1 or GPLv2 or LGPLv2 or Netscape) and Public
: Domain and ASL 2.0 and MPLv2.0 and CC0
Description : LibreOffice is an Open Source, community-developed, office productivity suite.
: It includes the key desktop applications, such as a word processor,
: spreadsheet, presentation manager, formula editor and drawing program, with a
: user interface and feature set similar to other office suites. Sophisticated
: and flexible, LibreOffice also works transparently with a variety of file
: formats, including Microsoft Office File Formats.
[root@localhost philip]#
Based on the preceding screenshot, we can see a lot of useful information for a given package. We can also check for system updates by using the check-update option:
[root@localhost philip]# dnf check-update
Last metadata expiration check: 0:18:17 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
GeoIP-GeoLite-data.noarch 2018.06-1.fc28 updates
LibRaw.x86_64 0.18.13-1.fc28 updates
rkManager-openvpn.x86_64 1:1.8.4-1.fc28 updates
NetworkManager-openvpn-gnome.x86_64 1:1.8.4-1.fc28 updates
grub2-tools-extra.x86_64 1:2.02-38.fc28 updates
grub2-tools.x86_64 1:2.02-34.fc28 @anaconda
grub2-tools-minimal.x86_64 1:2.02-38.fc28 updates
grub2-tools.x86_64 1:2.02-34.fc28 @anaconda
kernel-headers.x86_64 4.17.9-200.fc28 updates
kernel-headers.x86_64 4.16.3-301.fc28 @anaconda
[root@localhost philip]#
To install a package, we use the install option:
[root@localhost philip]# dnf install BitchX.x86_64
Last metadata expiration check: 0:20:30 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
Dependencies resolved.
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Installing:
BitchX x86_64 1.2.1-15.fc28 fedora 1.6 M
Transaction Summary
==========================================================================================================================
Install 1 Package
Total download size: 1.6 M
Installed size: 3.3 M
Is this ok [y/N]: y
Installed:
BitchX.x86_64 1.2.1-15.fc28
Complete!
[root@localhost philip]#
Great job! As you will be able to see by now, the options are similar to their older YUM counterparts. Similarly, to remove a package, we use the remove option:
[root@localhost philip]# dnf remove BitchX.x86_64
Dependencies resolved.
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Removing:
BitchX x86_64 1.2.1-15.fc28 @fedora 3.3 M
Transaction Summary
==========================================================================================================================
Remove 1 Package
Freed space: 3.3 M
Is this ok [y/N]: y
Running transaction check
Preparing : 1/1
Erasing : BitchX-1.2.1-15.fc28.x86_64 1/1
Verifying : BitchX-1.2.1-15.fc28.x86_64 1/1
Removed:
BitchX.x8
6_64 1.2.1-15.fc28
Complete!
[root@localhost philip]#
We can also remove packages that were only needed to satisfy dependencies. To do so, we use the autoremove option:
[root@localhost philip]# dnf autoremove
Last metadata expiration check: 0:25:12 ago on Tue 31 Jul 2018 03:10:57 PM EDT.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost philip]#
If we would like to see the various dnf commands that were executed, we can use the history option:
[root@localhost philip]# dnf history
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
3 | remove BitchX.x86_64 | 2018-07-31 15:33 | Erase | 1
2 | install BitchX.x86_64 | 2018-07-31 15:31 | Install | 1
1 | | 2018-04-25 02:33 | Install | 1596 EE
[root@localhost philip]#
This is very useful when we're trying to track what has changed in our system. Before we perform any updates to our system, it's always a good idea to do some housekeeping. We can use the clean all option for this:
[root@localhost philip]# dnf clean all
18 files removed
[root@localhost philip]#
Finally, to update all packages on the system, we use the update option:
[root@localhost philip]# dnf update
Last metadata expiration check: 0:11:49 ago on Tue 31 Jul 2018 03:48:23 PM EDT.
Dependencies resolved.
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Upgrading:
GeoIP-GeoLite-data noarch 2018.06-1.fc28 updates 551 k
LibRaw x86_64 0.18.13-1.fc28 updates
libkcapi x86_64 1.1.1-6.fc28 updates 44 k
libkcapi-hmaccalc x86_64 1.1.1-6.fc28 updates 26 k
libnice x86_64 0.1.14-7.20180504git34d6044.fc28 updates 173 k
libvirt-daemon-config-network x86_64 4.1.0-3.fc28 updates 10 k
rpm-sign-libs x86_64 4.14.1-9.fc28 updates 73 k
xmlsec1-nss x86_64 1.2.25-4.fc28 updates 79 k
Transaction Summary
==========================================================================================================================
Install 11 Packages
Upgrade 736 Packages
Total download size: 1.0 G
Is this ok [y/N]: y
We can also pass the upgrade option, which is newer:
[root@localhost philip]# dnf upgrade
Last metadata expiration check: 0:11:49 ago on Tue 31 Jul 2018 03:48:23 PM EDT.
Dependencies resolved.
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Upgrading:
GeoIP-GeoLite-data noarch 2018.06-1.fc28 updates 551 k
LibRaw x86_64 0.18.13-1.fc28 updates
libkcapi x86_64 1.1.1-6.fc28 updates 44 k
libkcapi-hmaccalc x86_64 1.1.1-6.fc28 updates 26 k
libnice x86_64 0.1.14-7.20180504git34d6044.fc28 updates 173 k
libvirt-daemon-config-network x86_64 4.1.0-3.fc28 updates 10 k
rpm-sign-libs x86_64 4.14.1-9.fc28 updates 73 k
xmlsec1-nss x86_64 1.2.25-4.fc28 updates 79 k
Transaction Summary
==========================================================================================================================
Install 11 Packages
Upgrade 736 Packages
Total download size: 1.0 G
Is this ok [y/N]: y
As we can see, the process is identical.