A Quick Guide to DNF Package Manager

DNF is the default package deal administration system on most RPM-based Linux distributions right now.

DNF downloads packages from repositories, installs, removes, and updates packages. It performs automated dependency decision for packages you put in, replace, or take away, and installs all packages required to fulfill dependency necessities.

On Fedora it’s the default package deal supervisor since Fedora 22. On RHEL 8.x it’s now the default package deal supervisor.

DNF offers safe package deal administration by enabling GPG signature verification on GPG signed packages. DNF won’t set up packages that aren’t signed with the proper key for that repository.

For backward compatibility, RHEL 8.x additionally has a YUM command, though it’s a hyperlink to DNF.

Why DNF?

DNF or Dandified YUM is the subsequent technology of YUM. In comparison with YUM, DNF has higher reminiscence utilization, improved dependency administration, and the power to make use of each Python 2 and Python 3.

Package deal administration with DNF

You have to have superuser privileges to make use of the DNF command to put in, replace, or uninstall the package deal. The next is a sequence of DNF instructions generally utilized by system directors.

Discover a package deal

To seek for a package deal that’s put in or accessible in all repositories, utilization

$ sudo dnf search <em>package_name</em>

For instance, to seek for package deal Nmap:

$ sudo dnf search nmap
Final metadata expiration examine: 0:05:14 in the past on Tue 02 Jun 2020 08:38:09 PM UTC.
==================================== Title Precisely Matched: nmap =====================================
nmap.x86_64 : Community exploration device and safety scanner
=================================== Title & Abstract Matched: nmap ====================================
nmap-ncat.x86_64 : Nmap's Netcat alternative

Checklist packages

To see a listing of all put in and accessible packages:

$ sudo dnf listing all
Put in Packages
GConf2.x86_64                                        3.2.6-22.el8                                      @rhui-rhel-8-for-x86_64-appstream-rhui-rpms
NetworkManager.x86_64                                1:1.22.8-4.el8                                    @anaconda
NetworkManager-libnm.x86_64                          1:1.22.8-4.el8                                    @anaconda
NetworkManager-team.x86_64                           1:1.22.8-4.el8                                    @anaconda
NetworkManager-tui.x86_64                            1:1.22.8-4.el8 
...

To listing all put in packages:

$ sudo dnf listing put in

Put in Packages
NetworkManager.x86_64             1:1.22.8-4.el8          @anaconda                                  
NetworkManager-libnm.x86_64       1:1.22.8-4.el8          @anaconda                                  
NetworkManager-team.x86_64        1:1.22.8-4.el8          @anaconda                                  
NetworkManager-tui.x86_64         1:1.22.8-4.el8          @anaconda                                  
PackageKit.x86_64                 1.1.12-4.el8            @AppStream                                 
PackageKit-glib.x86_64            1.1.12-4.el8            @AppStream                                 
WALinuxAgent.noarch               2.2.38-1.el8            @rhui-rhel-8-for-x86_64-appstream-rhui-rpms
abattis-cantarell-fonts.noarch    0.0.25-4.el8            @AppStream                                 
acl.x86_64                        2.2.53-1.el8            @anaconda 
...                                                                      

To show all accessible packages:

$ sudo dnf listing accessible
Final metadata expiration examine: 1:15:10 in the past on Tue 02 Jun 2020 05:37:11 PM UTC.
Out there Packages
CUnit.i686                                           2.1.3-17.el8                                      rhui-rhel-8-for-x86_64-appstream-rhui-rpms
CUnit.x86_64                                         2.1.3-17.el8                                      rhui-rhel-8-for-x86_64-appstream-rhui-rpms
CUnit-devel.i686                                     2.1.3-17.el8                                      rhui-codeready-builder-for-rhel-8-x86_64-rhui-rpms
CUnit-devel.x86_64                                   2.1.3-17.el8                                      rhui-codeready-builder-for-rhel-8-x86_64-rhui-rpms
...

For instance, to listing all MySQL packages accessible:

$ sudo dnf listing accessible "mysql*"
Final metadata expiration examine: 1:17:04 in the past on Tue 02 Jun 2020 05:37:11 PM UTC.
Out there Packages
mysql.x86_64        8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms
mysql-common.x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms
mysql-devel.x86_64  8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms
mysql-errmsg.x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms
mysql-libs.x86_64   8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms
mysql-server.x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms
mysql-test.x86_64   8.0.17-3.module+el8.0.0+3898+e09bb8de  rhui-rhel-8-for-x86_64-appstream-rhui-rpms

View package deal info

View details about a package deal:

$ sudo dnf data <em>package_name
</em>

For instance, to show details about the httpd server:

$ sudo dnf data httpd
Final metadata expiration examine: 0:15:04 in the past on Mon 01 Jun 2020 11:23:11 PM UTC.
Out there Packages
Title         : httpd
Model      : 2.4.37
Launch      : 21.module+el8.2.0+5008+cca404a3
Structure : x86_64
Dimension         : 1.4 M
Supply       : httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.src.rpm
Repository   : rhui-rhel-8-for-x86_64-appstream-rhui-rpms
Abstract      : Apache HTTP Server
URL          : https://httpd.apache.org/
License      : ASL 2.0
Description  : The Apache HTTP Server is a robust, environment friendly, and extensible
             : internet server.

Set up packages

Set up one package deal

To put in a single package deal and all its uninstalled dependencies:

$ sudo dnf set up package_name

For instance, Set up Nginx:

$ sudo dnf set up nginx
Dependencies resolved.
===========================================================================================
 Package deal             Arch   Model       Repository                                  Dimension
===========================================================================================
Putting in:
 nginx               x86_64 1:1.14.1-9.module+el8.0.0+4108+af250afe
                                          rhui-rhel-8-for-x86_64-appstream-rhui-rpms 570 okay
Putting in dependencies:
 gd                  x86_64 2.2.5-6.el8   rhui-rhel-8-for-x86_64-appstream-rhui-rpms 144 okay
 jbigkit-libs        x86_64 2.1-14.el8    rhui-rhel-8-for-x86_64-appstream-rhui-rpms  55 okay
..

This may set up Nginx and all its uninstalled dependency necessities.

Set up a number of packages

You can too set up a number of packages by including package deal names to this command. For instance, to put in Nginx, PHP & MySQL server, enter:

$ sudo dnf set up nginx php mysql-server
Dependencies resolved.
===========================================================================================
 Package deal          Arch   Model          Repository                                  Dimension
===========================================================================================
Putting in:
 mysql-server     x86_64 8.0.17-3.module+el8.0.0+3898+e09bb8de
                                          rhui-rhel-8-for-x86_64-appstream-rhui-rpms  22 M
 nginx            x86_64 1:1.14.1-9.module+el8.0.0+4108+af250afe
                                          rhui-rhel-8-for-x86_64-appstream-rhui-rpms 570 okay
 php              x86_64 7.2.24-1.module+el8.2.0+4601+7c76a223
                                          rhui-rhel-8-for-x86_64-appstream-rhui-rpms 1.5 M
Putting in dependencies:
 apr              x86_64 1.6.3-9.el8      rhui-rhel-8-for-x86_64-appstream-rhui-rpms 125 okay
 apr-util         x86_64 1.6.1-6.el8      rhui-rhel-8-for-x86_64-appstream-rhui-rpms 105 okay
 gd               x86_64 2.2.5-6.el8      rhui-rhel-8-for-x86_64-appstream-rhui-rpms 144 okay
 httpd            x86_64 2.4.37-21.module+el8.2.0+5008+cca404a3
                                          rhui-rhel-8-for-x86_64-appstream-rhui-rpms 1.4 M
 httpd-filesystem noarch 2.4.37-21.module+el8.2.0+5008+cca404a3
...

Set up a package deal based mostly on the binary file title

If you recognize the title of the binary you need to set up, however not the package deal title, even that is sufficient to set up the related package deal.

For instance, when you enter:

$ sudo dnf set up /usr/sbin/named
Final metadata expiration examine: 1:21:25 in the past on Tue 02 Jun 2020 05:37:11 PM UTC.
Dependencies resolved.
=====================================================================================================
 Package deal   Arch        Model                 Repository                                       Dimension
=====================================================================================================
Putting in:
 bind      x86_64      32:9.11.13-5.el8_2      rhui-rhel-8-for-x86_64-appstream-rhui-rpms      2.1 M

Transaction Abstract
=====================================================================================================
Set up  1 Package deal

Whole obtain dimension: 2.1 M
Put in dimension: 4.5 M
Is that this okay [y/N]:

DNF searches and finds the package deal that gives it /usr/sbin/known as and asks you to put in it.

Discover which package deal owns a file

If you recognize the file title and need to know what package deal it offers (put in or not), use:

$ sudo dnf offers <em>file_name</em>

For instance, to seek out which package deal offers a reputation, use the binary for the DNS server:

$ sudo dnf offers named
Final metadata expiration examine: 1:27:30 in the past on Mon 01 Jun 2020 11:23:11 PM UTC. 
bind-32:9.11.4-16.P2.el8.x86_64 : 
The Berkeley Web Title Area (BIND) DNS (Area Title System) : 
server Repo : rhui-rhel-8-for-x86_64-appstream-rhui-rpms Matched from: Filename : 
/usr/sbin/named

Delete a package deal

To delete a package deal:

sudo dnf take away <em>package_name</em>

However watch out, DNF can’t take away a package deal with out additionally eradicating the packages that rely upon it. To take away package deal nmap use:

$ sudo dnf take away nmap
Dependencies resolved.
=====================================================================================================
 Package deal    Structure Model             Repository                                         Dimension
=====================================================================================================
Eradicating:
 nmap       x86_64       2:7.70-5.el8        @rhui-rhel-8-for-x86_64-appstream-rhui-rpms        24 M

Transaction Abstract
=====================================================================================================
Take away  1 Package deal

Freed area: 24 M
Is that this okay [y/N]:

Handle package deal teams

A package deal group is a set of packages which might be carefully associated and serve a standard function. Putting in a package deal group installs a sequence of packages, saving a number of time.

Checklist all package deal teams

To show all package deal teams:

$ sudo dnf group listing
Out there Setting Teams:
   Server with GUI
   Server
   Workstation
   Customized Working System
   Virtualization Host
Put in Setting Teams:
   Minimal Set up
Put in Teams:
   Safety Instruments
   Container Administration
Out there Teams:
   Legacy UNIX Compatibility
   Growth Instruments
   Scientific Help
   .NET Core Growth
   Graphical Administration Instruments
   Headless Administration
   RPM Growth Instruments
   Community Servers
   System Instruments
   Sensible Card Help

Checklist all packages in a gaggle

To listing all packages in a gaggle:

$ sudo dnf group data <em>package_name</em>

For instance, to view packages within the Safety Instruments group:

$ sudo dnf group data “safety instruments”
Group: Safety Instruments
 Description: Safety instruments for integrity and belief verification.
 Default Packages:
   scap-security-guide
 Non-obligatory Packages:
   aide
   hmaccalc
   openscap
   openscap-engine-sce
   openscap-utils
   scap-security-guide-doc
   scap-workbench
   tpm-quote-tools
   tpm-tools
   tpm2-tools
   trousers

Set up a package deal group

Putting in a gaggle installs all packages in a gaggle. To put in a package deal group use:

sudo dnf group set up <em>package_group_name</em>

For instance, to put in the “Community Servers” group:

$ sudo dnf group set up “Community Servers”
Final metadata expiration examine: 1:40:14 in the past on Wed 03 Jun 2020 05:53:11 PM UTC.
Dependencies resolved.
===========================================================================================
 Package deal              Structure        Model               Repository            Dimension
===========================================================================================
Putting in Teams:
 Community Servers                                                                          

Transaction Abstract
===========================================================================================

Is that this okay [y/N]:

Delete a package deal group

To delete a package deal group:

sudo dnf take away <em>package_name</em>

So to take away the “Safety Instruments” package deal group:

$ sudo dnf group take away "safety instruments"
Dependencies resolved.
=====================================================================================================
 Package deal               Arch     Model          Repository                                     Dimension
=====================================================================================================
Eradicating:
 scap-security-guide   noarch   0.1.48-7.el8     @rhui-rhel-8-for-x86_64-appstream-rhui-rpms   182 M
Eradicating unused dependencies:
 GConf2                x86_64   3.2.6-22.el8     @rhui-rhel-8-for-x86_64-appstream-rhui-rpms   6.3 M
 libxslt               x86_64   1.1.32-4.el8     @rhui-rhel-8-for-x86_64-baseos-rhui-rpms      734 okay
 openscap              x86_64   1.3.2-6.el8      @rhui-rhel-8-for-x86_64-appstream-rhui-rpms    58 M
 openscap-scanner      x86_64   1.3.2-6.el8      @rhui-rhel-8-for-x86_64-appstream-rhui-rpms   137 okay
 xml-common            noarch   0.6.3-50.el8     @rhui-rhel-8-for-x86_64-baseos-rhui-rpms       78 okay
Eradicating Teams:
 Safety Instruments                                                                                     

Transaction Abstract
=====================================================================================================
Take away  6 Packages

Freed area: 247 M
Is that this okay [y/N]: 

Replace packages

Replace all packages

To replace all packages and their dependencies, you should use:

$ sudo dnf improve
Final metadata expiration examine: 1:09:31 in the past on Tue 02 Jun 2020 08:38:09 PM UTC.
Dependencies resolved.
Nothing to do.
Full!

This may set up all updates that may be put in. Each dnf improve and dnf replace have the identical impact, however a dnf improve is most well-liked.

Replace one package deal

To replace a single package deal, run:

$ sudo dnf improve package_name

For instance, to replace the Python package deal:

$ sudo dnf improve python

Conclusion

Studying DNF might be worthwhile as it’s typically the quickest solution to carry out system administration duties. In the event you’re eager about studying RHEL 8, take a look at this Udemy course.

Rate this post
Leave a Comment