dnf
Linux/Unix

DNF software package manager in Linux

DNF ( DaNdified Yum ) is the new generation of yum, it replaces yum of RMP package manager based systems like RedHat, Fedora and CentOS. It several advantages over yum, such as support for multiple repositories, less memory consumption, fast dependency management and more.

In this guide we will see some essential examples of the dnf command to know.

Installation :

dnf is installed by default on Fedora 22 and CentOS 8, however it’s not for CentOS 7 and RHEL7, to install it just use the command below:

[root@server ~]# yum install dnf
.
.
.
Installed:
  dnf.noarch 0:4.0.9.2-2.el7_9


Dependency Installed:
  deltarpm.x86_64 0:3.6-3.el7                                 dnf-data.noarch 0:4.0.9.2-2.el7_9               libcomps.x86_64 0:0.1.8-14.el7
  libdnf.x86_64 0:0.22.5-2.el7_9                              libmodulemd.x86_64 0:1.6.3-1.el7                librepo.x86_64 0:1.8.1-8.el7_9
  libreport-filesystem.x86_64 0:2.1.11-53.el7.centos          libsolv.x86_64 0:0.6.34-4.el7                   libyaml.x86_64 0:0.1.4-11.el7_0
  python-enum34.noarch 0:1.0.4-1.el7                          python2-dnf.noarch 0:4.0.9.2-2.el7_9            python2-hawkey.x86_64 0:0.22.5-2.el7_9
  python2-libcomps.x86_64 0:0.1.8-14.el7                      python2-libdnf.x86_64 0:0.22.5-2.el7_9

Complete!

Somme example of DNF Commands :

Display dnf version :

[root@server ~]# dnf --version
4.0.9
  Installed: dnf-0:4.0.9.2-2.el7_9.noarch at Tue 21 Sep 2021 11:19:25 AM EST
  Built    : CentOS BuildSystem <http://bugs.centos.org> at Wed 07 Apr 2021 03:52:38 PM EST

Install a package :

[root@server ~]# dnf install net-tools
.
.
.
Downloading Packages:
net-tools-2.0-0.25.20131004git.el7.x86_64.rpm                                                                                 666 kB/s | 306 kB     00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                         337 kB/s | 306 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                      1/1
  Installing       : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                            1/1
  Running scriptlet: net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                            1/1
  Verifying        : net-tools-2.0-0.25.20131004git.el7.x86_64                                                                                            1/1

Installed:
  net-tools-2.0-0.25.20131004git.el7.x86_64

Complete!

You can install multiple packages with one command :

[root@server ~]#  dnf vim install bash-completion net-tools

Display information about a package :

To display information on a package, whether it is installed or not, use the command below :

[root@server ~]# dnf info net-tools
Last metadata expiration check: 0:17:18 ago on Tue 21 Sep 2021 07:25:58 AM EDT.
Installed Packages
Name         : net-tools
Version      : 2.0
Release      : 0.25.20131004git.el7
Arch         : x86_64
Size         : 917 k
Source       : net-tools-2.0-0.25.20131004git.el7.src.rpm
Repo         : @System
From repo    : base
Summary      : Basic networking tools
URL          : http://sourceforge.net/projects/net-tools/
License      : GPLv2+
Description  : The net-tools package contains basic networking tools,
             : including ifconfig, netstat, route, and others.
             : Most of them are obsolete. For replacement check iproute package.

Update a package :

[root@server ~]# dnf update net-tools
Last metadata expiration check: 0:20:43 ago on Tue 21 Sep 2021 07:25:58 AM EDT.
Dependencies resolved.
Nothing to do.
Complete!

As you can see, net-tools package is already up to date.

Checking the updates for a package :

If you want to know if there are any updates for an installed package, just type :

[root@server ~]# dnf list python-firewall.noarch
Last metadata expiration check: 0:26:47 ago on Tue 21 Sep 2021 07:25:58 AM EDT.
Installed Packages
python-firewall.noarch                                                         0.6.3-12.el7                                                            @System
Available Packages
python-firewall.noarch                                                         0.6.3-13.el7_9                                                          updates

« @system » indicates the current package, while « updates » indicates the new package available on the repository.

if you want to check the updates for all installed packages, use the following command:

[root@server ~]# dnf check-update
Last metadata expiration check: 0:34:10 ago on Tue 21 Sep 2021 07:25:58 AM EDT.

bind-export-libs.x86_64                                                        32:9.11.4-26.P2.el7_9.7                                                 updates
bind-libs.x86_64                                                               32:9.11.4-26.P2.el7_9.7                                                 updates
bind-libs-lite.x86_64                                                          32:9.11.4-26.P2.el7_9.7                                                 updates
bind-license.noarch                                                            32:9.11.4-26.P2.el7_9.7                                                 updates
bind-utils.x86_64                                                              32:9.11.4-26.P2.el7_9.7                                                 updates
device-mapper.x86_64                                                           7:1.02.170-6.el7_9.5                                                    updates
device-mapper-event.x86_64                                                     7:1.02.170-6.el7_9.5                                                    updates
device-mapper-event-libs.x86_64                                                7:1.02.170-6.el7_9.5                                                    updates
device-mapper-libs.x86_64                                                      7:1.02.170-6.el7_9.5                                                    updates
dhclient.x86_64                                                                12:4.2.5-83.el7.centos.1                                                updates
dhcp-common.x86_64                                                             12:4.2.5-83.el7.centos.1                                                updates
dhcp-libs.x86_64                                                               12:4.2.5-83.el7.centos.1                                                updates
firewalld.noarch                                                               0.6.3-13.el7_9                                                          updates
firewalld-filesystem.noarch                                                    0.6.3-13.el7_9                                                          updates
glib2.x86_64                                                                   2.56.1-9.el7_9                                                          updates

Update all packages :

[root@srv ~]# dnf update
[root@srv ~]# dnf upgrade

Download a package without installing it :

You can do that with the following command :

[root@server ~]# dnf-download samba
dnf

Delete a package :

[root@server ~]# dnf remove net-tools
Dependencies resolved.
==============================================================================================================================================================
 Package                            Arch                            Version                                              Repository                      Size
==============================================================================================================================================================
Removing:
 net-tools                          x86_64                          2.0-0.25.20131004git.el7                             @base                          917 k

Transaction Summary
==============================================================================================================================================================
Remove  1 Package

Freed space: 917 k
Is this ok [y/N]:

List installed packages :

[root@server ~]# dnf list installed
Installed Packages
NetworkManager.x86_64                                                      1:1.18.8-2.el7_9                                                      @System
NetworkManager-libnm.x86_64                                                1:1.18.8-2.el7_9                                                      @System
NetworkManager-team.x86_64                                                 1:1.18.8-2.el7_9                                                      @System
NetworkManager-tui.x86_64                                                  1:1.18.8-2.el7_9                                                      @System
acl.x86_64                                                                 2.2.51-15.el7                                                         @System
aic94xx-firmware.noarch                                                    30-6.el7                                                              @System
alsa-firmware.noarch                                                       1.0.28-2.el7                                                          @System
alsa-lib.x86_64                                                            1.1.8-1.el7                                                           @System
alsa-tools-firmware.x86_64                                                 1.1.0-1.el7                                                           @System
apr.x86_64                                                                 1.4.8-7.el7                                                           @System

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *