DNF Guide for Beginners with 20 Examples

DNF stands for Dandified YUM it is completely an updated version of YUM Package Manager. It was originally introduced on Fedora 18, and now it becomes a default package manager on Fedora 22, RHEL, and CentOS-8 to handle the RPM packages management. DNF improves the deficiencies of YUM, include poor performance, high memory usage, slowness for dependency resolution. The current and stable version of DNF is 4.2.7.

In this article, how to use dnf commands in Fedora, CentOS, and RHEL with many sub-commands, it will help to all the Newbies and System Admins. All the following examples of dnf commands are tested on RHEL and CentOS 8.

Recommended to read: 15 Useful YUM commands for Beginners in Linux

Prerequisites :

Operating System : Fedora / CentOS / RHEL  
User account     : root user or user account with sudo privileges
Recommended to run all the administrative command as with sudo privilege instead of root.

Difficulties to setup sudo users? –> Click here to find the steps <–.

The Global Syntax of dnf command in Linux:

dnf [options] [command] [package …]

The following table provides an overview of the options of ‘dnf’ command in Fedora, RHEL / CentOS 8

DNF Guide for Beginners with 20 Examples 1

1. How to check whether any packages are available for updates?

$ sudo dnf check-update

anaconda-core.x86_64                        AppStream 
anaconda-gui.x86_64                         AppStream 
anaconda-tui.x86_64                         AppStream 
anaconda-user-help.noarch       1:8.2.3-1.el8                         AppStream 
anaconda-widgets.x86_64                      AppStream 
appstream-data.noarch           8-20191129.el8                        AppStream 
audit.x86_64                    3.0-0.17.20191104git1c2f876.el8       BaseOS    
audit-libs.x86_64               3.0-0.17.20191104git1c2f876.el8       BaseOS    
augeas-libs.x86_64              1.12.0-5.el8                          BaseOS    
baobab.x86_64                   3.28.0-4.el8                          AppStream 



With the above command, we can get the list of all packages from our enabled repositories for an update to our existing packages that are available in our system. Always try to use this command before you make your system update, as sometimes the new packages are not feasible with your hardware or your existing applications.
2. How to install a new package?

$ sudo dnf install vsftpd

Dependencies resolved.
 Package                   Architecture         Version        Repository          Size
 vsftpd                    x86_64             3.0.3-31.el8      AppStream         180 k

Transaction Summary
Install  1 Package

Total download size: 180 k
Installed size: 343 k
Is this ok [y/N]: y 


Using the above command we can install a new package. During the execution of this command, you will be prompt for a confirmation and we need to enter ‘y’ (yes) to proceed installation. However, we can avoid these confirmation messages while installation time by using ‘-y’ at the end of the above command. You can see, in this example, we have successfully installed a “vsftpd” package.
3. How to update a specific package?

$ sudo dnf update passwd -y

Dependencies resolved.
 Package                   Architecture         Version        Repository          Size
 passwd                    x86_64              0.80-3.el8      BaseOS             115 k

Transaction Summary
Upgrade  1 Package


In this example, I have picked only a particular package named ‘passwd’ to update from the whole set of new releases. However, if you want to update the entire system, just use the following command.

$sudo dnf update -y

4. How to exclude a particular package from being updated?


In the following output, you can see that I have highlighted two (“firewalld”) packages, that I am going to exclude from the whole set of updates in my system.

$ sudo dnf check-update

exiv2-libs.x86_64                               0.27.2-5.el8                AppStream 
file.x86_64                                     5.33-13.el8                 BaseOS    
file-libs.x86_64                                5.33-13.el8                 BaseOS    
firefox.x86_64                                  68.10.0-1.el8_2             AppStream 
firewalld.noarch                                0.8.0-4.el8                 BaseOS    
firewalld-filesystem.noarch                     0.8.0-4.el8                 BaseOS    
flatpak.x86_64                                  1.6.2-2.el8                 AppStream 
flatpak-libs.x86_64                             1.6.2-2.el8                 AppStream

$ sudo dnf update -x firewalld* –nobest

Dependencies resolved.
 Package                                    ArchVersion                                        Repo      Size
 exiv2                                      x86_640.27.2-5.el8                                   AppStream 1.0 M
 exiv2-libs                                 x86_640.27.2-5.el8                                   AppStream 851 k
 firefox                                    x86_6468.10.0-1.el8_2                                AppStream 94  M
 flatpak                                    x86_641.6.2-2.el8                                    AppStream 1.5 M
 flatpak-libs                               x86_641.6.2-2.el8                                    AppStream 413 k
 fprintd                                    x86_641.90.0-0.20191121gitf022902.el8                AppStream 103 k
 Skipping packages with conflicts:
 (add '--best --allowerasing' to the command line to force their upgrade):
 python3-firewall                                  noarch          0.8.0-4.el8                   BaseOS     389 k

 Transaction Summary
 Install   18 Packages
 Upgrade  572 Packages
 Skip       1 Package

 Total download size: 631 M
 Is this ok [y/N]: y


In the above output, you can see there are no firewalld packages that appeared. I have just copied the same lines to give you an idea about it. Similarly, if you want to exclude, more than one (multi) package in a single line command use the following command.

$ sudo dnf update -x package_name1* -x package_name2* –nobest

5. How to install only the security updates?


It is always recommended to update security fixes regularly as it can prevent vulnerabilities. Using the following command, we can fetch only the security fixes from our enabled repositories and install/updates in our systems.

$ sudo dnf updateinfo list –security


$ sudo dnf upgrade –security

6. How to uninstall a specific package?

$ sudo dnf remove vsftpd

Dependencies resolved.
 Package                Architecture        Version               Repository         Size
 vsftpd                 x86_64              3.0.3-31.el8          @AppStream         343 k

Transaction Summary
Remove  1 Package

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


We can uninstall the packages by using the ‘remove’ dnf sub-command. The most important thing is we should not use the auto-confirmation using ‘-y’ with remove sub-command, as sometimes it may remove the dependencies along with the primary package, and it could affect the packages that still required those dependencies. In case if you have any such situation, it is recommended to use our traditional method to uninstall the rpm packages by using ‘rpm -e –nodeps package_Name’ to avoid such dependency issues. In our example, we have removed the “vsftpd” package which was installed in the previous example.
7. How to get the list of all the combined packages?

$ sudo dnf list all

 Output:   (Installed Packages)
exiv2-libs.x86_64                     0.26-10.el8                                  @AppStream
expat.x86_64                          2.2.5-3.el8                                  @anaconda 
file.x86_64                           5.33-8.el8                                   @anaconda 
file-libs.x86_64                      5.33-8.el8                                   @anaconda 
file-roller.x86_64                    3.28.1-2.el8                                 @AppStream
                (Available Packages)
brotli-devel.x86_64                   1.0.6-1.el8                                  AppStream 
bsdtar.x86_64                         3.3.2-8.el8_1                                BaseOS    
bubblewrap.x86_64                     0.4.0-1.el8                                  BaseOS    
buildah.x86_64                        1.11.6-7.module_el8.2.0+305+5e198a41         AppStream 
buildah-tests.x86_64                  1.11.6-7.module_el8.2.0+305+5e198a41         AppStream 


Using the above command, we can get a list of all the installed and available packages. Also, we can filter a particular package from our system by using the glob-expression or piped with grep. In our example, I am going to filter the sssd (System Security Services Daemon package) package by using the following command.

$ sudo dnf list installed “sssd-?*” –nobest OR $ sudo dnf list installed | grep sssd-

Installed Packages
sssd-ad.x86_64                        2.2.0-19.el8                                 @anaconda
sssd-client.x86_64                    2.2.0-19.el8                                 @anaconda
sssd-common.x86_64                    2.2.0-19.el8                                 @anaconda
sssd-common-pac.x86_64                2.2.0-19.el8                                 @anaconda
sssd-ipa.x86_64                       2.2.0-19.el8                                 @anaconda
sssd-kcm.x86_64                       2.2.0-19.el8                                 @anaconda
sssd-krb5.x86_64                      2.2.0-19.el8                                 @anaconda
sssd-krb5-common.x86_64               2.2.0-19.el8                                 @anaconda
sssd-ldap.x86_64                      2.2.0-19.el8                                 @anaconda
sssd-nfs-idmap.x86_64                 2.2.0-19.el8                                 @anaconda
sssd-proxy.x86_64                     2.2.0-19.el8                                 @anaconda
8. How to reinstall a package?

$ sudo dnf reinstall vsftpd

Dependencies resolved.
 Package                          Architecture       Version               Repository            Size
 vsftpd                           x86_64             3.0.3-31.el8          AppStream              180 k

Transaction Summary

Total download size: 180 k
Installed size: 343 k
Is this ok [y/N]: y


This command is very helpful and time-saving. Earlier, if we have any issues with existing installed packages, then we normally remove the package and then install it back, but now, it can be done by using a single ‘reinstall’ sub-command.
9. How to view detailed information about a particular package?

$ sudo dnf info vsftpd

Installed Packages
Name         : vsftpd
Version      : 3.0.3
Release      : 31.el8
Architecture : x86_64
Size         : 343 k
Source       : vsftpd-3.0.3-31.el8.src.rpm
Repository   : @System
From repo    : AppStream
Summary      : Very Secure Ftp Daemon
URL          : https://security.appspot.com/vsftpd.html
License      : GPLv2 with exceptions
Description  : vsftpd is a Very Secure FTP daemon. It was written completely from
             : scratch.


With the above command, we can find detailed information about a particular package. In the output, you can see the complete information about a package such as version number, release date, architecture, size, summary.
10. How to download an .rpm package file?


Some times we have certain scenarios where we need to install a specific list of RPM packages on a server with no Internet connection on it. In those cases, we need to download that specific RPM packages from some other PC. In this example, we will see how to download the RPM extension file for “samba” by using the following command.

$ sudo dnf download samba

[sudo] password for linuxteck: 
Last metadata expiration check: 21:36:25 ago on Monday 13 July 2020 07:14:36 PM IST.


As you can see above, that we have downloaded the .rpm file for samba and now the following command will show how to download RPM files with dependencies.

$ sudo dnf download samba –resolve

(1/26): samba-libs-4.11.2-13.el8.x86_64.rpm                  68 kB/s | 170 kB     00:02    
(2/26): libipa_hbac-2.2.3-20.el8.x86_64.rpm                  76 kB/s | 103 kB     00:01    
(3/26): samba-common-tools-4.11.2-13.el8.x86_64.rpm         109 kB/s | 472 kB     00:04    
(4/26): libldb-2.0.7-3.el8.x86_64.rpm                       255 kB/s | 180 kB     00:00    
(5/26): libsmbclient-4.11.2-13.el8.x86_64.rpm               228 kB/s | 146 kB     00:00    
(6/26): libtalloc-2.2.0-7.el8.x86_64.rpm                    238 kB/s |  49 kB     00:00    
(7/26): samba-4.11.2-13.el8.x86_64.rpm                      147 kB/s | 766 kB     00:05    
(8/26): libsss_idmap-2.2.3-20.el8.x86_64.rpm                168 kB/s | 107 kB     00:00    
(9/26): libtdb-1.4.2-2.el8.x86_64.rpm                       196 kB/s |  59 kB     00:00    
(10/26): libtevent-0.10.0-2.el8.x86_64.rpm                   84 kB/s |  49 kB     00:00    
(11/26): libwbclient-4.11.2-13.el8.x86_64.rpm               144 kB/s | 117 kB     00:00    
(12/26): python3-sssdconfig-2.2.3-20.el8.noarch.rpm         149 kB/s | 120 kB     00:00    
(13/26): samba-common-libs-4.11.2-13.el8.x86_64.rpm         241 kB/s | 173 kB     00:00    
(14/26): samba-common-4.11.2-13.el8.noarch.rpm              202 kB/s | 212 kB     00:01    
(15/26): sssd-2.2.3-20.el8.x86_64.rpm                       194 kB/s |  94 kB     00:00    
(16/26): sssd-ad-2.2.3-20.el8.x86_64.rpm                    234 kB/s | 235 kB     00:01    
(17/26): sssd-client-2.2.3-20.el8.x86_64.rpm                224 kB/s | 171 kB     00:00    
(18/26): sssd-common-pac-2.2.3-20.el8.x86_64.rpm            201 kB/s | 165 kB     00:00    
(19/26): sssd-ipa-2.2.3-20.el8.x86_64.rpm                   223 kB/s | 328 kB     00:01    
(20/26): sssd-kcm-2.2.3-20.el8.x86_64.rpm                    96 kB/s | 218 kB     00:02    
(21/26): sssd-common-2.2.3-20.el8.x86_64.rpm                228 kB/s | 1.5 MB     00:06    
(22/26): sssd-krb5-common-2.2.3-20.el8.x86_64.rpm           316 kB/s | 174 kB     00:00    
(23/26): sssd-krb5-2.2.3-20.el8.x86_64.rpm                   50 kB/s | 129 kB     00:02    
(24/26): sssd-ldap-2.2.3-20.el8.x86_64.rpm                  250 kB/s | 208 kB     00:00    
(25/26): sssd-proxy-2.2.3-20.el8.x86_64.rpm                  92 kB/s | 129 kB     00:01    
(26/26): samba-client-libs-4.11.2-13.el8.x86_64.rpm         311 kB/s | 5.1 MB     00:16   


In the above example, we can see there are 26 .rpm files are downloaded. If you want to view all the downloaded files, then use the ‘ls’ command. In ‘ls’ there are plenty of useful options available if you want to know more about it click here.

$ ls

libipa_hbac-2.2.3-20.el8.x86_64.rpm         samba-4.11.2-13.el8.x86_64.rpm               sssd-common-2.2.3-20.el8.x86_64.rpm
libldb-2.0.7-3.el8.x86_64.rpm               samba-client-libs-4.11.2-13.el8.x86_64.rpm   sssd-common-pac-2.2.3-20.el8.x86_64.rpm
libsmbclient-4.11.2-13.el8.x86_64.rpm       samba-common-4.11.2-13.el8.noarch.rpm        sssd-ipa-2.2.3-20.el8.x86_64.rpm
libsss_idmap-2.2.3-20.el8.x86_64.rpm        samba-common-libs-4.11.2-13.el8.x86_64.rpm   sssd-kcm-2.2.3-20.el8.x86_64.rpm
libtalloc-2.2.0-7.el8.x86_64.rpm            samba-common-tools-4.11.2-13.el8.x86_64.rpm  sssd-krb5-2.2.3-20.el8.x86_64.rpm
libtdb-1.4.2-2.el8.x86_64.rpm               samba-libs-4.11.2-13.el8.x86_64.rpm          sssd-krb5-common-2.2.3-20.el8.x86_64.rpm
libtevent-0.10.0-2.el8.x86_64.rpm           sssd-2.2.3-20.el8.x86_64.rpm                 sssd-ldap-2.2.3-20.el8.x86_64.rpm
libwbclient-4.11.2-13.el8.x86_64.rpm        sssd-ad-2.2.3-20.el8.x86_64.rpm              sssd-proxy-2.2.3-20.el8.x86_64.rpm
python3-sssdconfig-2.2.3-20.el8.noarch.rpm  sssd-client-2.2.3-20.el8.x86_64.rpm
11. How to install a .rpm package file using dnf?

$ sudo dnf localinstall samba-4.11.2-13.el8.x86_64.rpm

Dependencies resolved.
 Package                       Architecture            Version                 Repository     
 samba                             x86_64             4.11.2-13.el8              @commandline              
 samba-common                      noarch             4.11.2-13.el8              BaseOS                    
 samba-common-libs                 x86_64             4.11.2-13.el8              BaseOS                    
 sssd                              x86_64             2.2.3-20.el8               BaseOS                    
 sssd-ad                           x86_64             2.2.3-20.el8               BaseOS                    
 sssd-proxy                        x86_64             2.2.3-20.el8               BaseOS                    
Installing dependencies:
 samba-common-tools                x86_64             4.11.2-13.el8              BaseOS                    
 samba-libs                        x86_64             4.11.2-13.el8              BaseOS                    

Transaction Summary
Install   3 Packages
Upgrade   5 Packages

Total size: 3 M
Total download size: 2 M
Is this ok [y/N]: y


As all, we know the traditional method of installing rpm files like “rpm -ivh xyz-1.2.3.rpm”, but it has some limitations as it cannot find or fetch the dependencies of the original rpm file. So we need to use the ‘dnf install’ command to install the dependencies first and then install the orginal rpm. We can overcome this, by using the dnf ‘localinstall’ sub-command, and it will install both dependencies and the parent package in a single command.
12. How to clear the cache details from the dnf cache directory?

$ sudo dnf clean all

[sudo] password for linuxteck: 
22 files removed


By default, dnf will be cached all the packaged information into the cache directory. As it will slightly boost-up the dnf performance, but at the same time, it has some drawbacks. The possible reason is, it may show the wrong version of the packages even after you have updated it to the latest version. Therefore, it is recommended to clear your cached data once in a while.
13. How to install a package group?


A package group is a virtual collection of packages similar to a regular package. Before jumping into the ‘group install’ sub-commands, let us see an overview of the group summary, like how many groups are installed, and available in our system. A summary is one of the basic groups subcommand.

$ sudo dnf groups summary

[sudo] password for linuxteck: 
CentOS-8 - AppStream                       106 kB/s | 5.8 MB     00:55    
CentOS-8 - Base                            104 kB/s | 2.2 MB     00:21    
CentOS-8 - Extras                          6.1 kB/s | 6.7 kB     00:01    
Installed Groups: 2
Available Groups: 10


In the above output, we can see the list of Installed and Available Groups, now let us check the list of available groups by using the following command.

$ sudo dnf grouplist

[sudo] password for linuxteck: 
CentOS-8 - AppStream                               229  B/s | 4.3 kB     00:19    
CentOS-8 - Base                                    562  B/s | 3.9 kB     00:07    
CentOS-8 - Extras                                  272  B/s | 1.5 kB     00:05    
Available Environment Groups:
   Minimal Install
   Virtualization Host
   Custom Operating System
Installed Environment Groups:
   Server with GUI
Installed Groups:
   Container Management
   Headless Management
Available Groups:
   .NET Core Development
   RPM Development Tools
   Development Tools
   Graphical Administration Tools
   Legacy UNIX Compatibility
   Network Servers
   Scientific Support
   Security Tools
   Smart Card Support
   System Tools


Now we have the list of all the available group packages. To understand more about each group, we need to use ‘groupinfo’ sub-command to find the packages that are included as a part of the individual group.

$ sudo dnf groupinfo “Server”

Environment Group: Server
 Description: An integrated, easy-to-manage server.
no group 'dns-server' from environment 'server-product-environment'
 Mandatory Groups:
   Container Management
   Hardware Support
   Headless Management
   Server product core
 Optional Groups:
   Basic Web Server
   Debugging Tools
   FTP Server
   File and Storage Server
   Guest Agents
   Hardware Monitoring Utilities
   Infiniband Support
   Mail Server
   Network File System Client
   Network Servers
   Performance Tools
   Remote Management for Linux
   Virtualization Hypervisor
   Windows File Server


From the above output, we can see the Server group is divided into two subgroups, Mandatory and Optional groups. If you want you can check each group’s details, then use the groupinfo sub-command with these group names. In our example, we are planning to install only the Web Server.

$ sudo dnf groupinfo “Basic Web Server”

Group: Basic Web Server
 Description: These tools allow you to run a Web server on the system.
 Mandatory Packages:
 Default Packages:
 Optional Packages:


Now we can see, the “Basic Web Server” group has bundled with the httpd and its related packages. So finally we can install the group package as shown below:

$ sudo dnf groupinstall “Basic Web Server”

Dependencies resolved.
 Package                            Architecture     Version                                        Repository       Size
Installing group/module packages:
 httpd                              x86_64           2.4.37-21.module_el8.2.0+382+15b0afa8          AppStream         1.7 M
 httpd-manual                       noarch           2.4.37-21.module_el8.2.0+382+15b0afa8          AppStream         2.4 M
 mod_fcgid                          x86_64           2.3.9-16.el8                                   AppStream          86 k
 mod_ssl                            x86_64           1:2.4.37-21.module_el8.2.0+382+15b0afa8        AppStream         132 k
Installing dependencies:
 apr                                x86_64           1.6.3-9.el8                                    AppStream         125 k
 apr-util                           x86_64           1.6.1-6.el8                                    AppStream         105 k
 httpd-filesystem                   noarch           2.4.37-21.module_el8.2.0+382+15b0afa8          AppStream          36 k
 httpd-tools                        x86_64           2.4.37-21.module_el8.2.0+382+15b0afa8          AppStream         103 k
 mod_http2                          x86_64           1.11.3-3.module_el8.2.0+307+4d18d695           AppStream         157 k
 centos-logos-httpd                 noarch           80.5-2.el8                                     BaseOS             24 k
Installing weak dependencies:
 apr-util-bdb                       x86_64           1.6.1-6.el8                                    AppStream          25 k
 apr-util-openssl                   x86_64           1.6.1-6.el8                                    AppStream          27 k
Enabling module streams:
 httpd                                               2.4                                                                                       
Installing Groups:
 Basic Web Server                                                                                                                                    

Transaction Summary
Install  12 Packages

Total download size: 4.8 M
Installed size: 14 M
Is this ok [y/N]: y


From the above output we can that we have successfully installed the httpd and its dependencies and other related modules.
14. How to search package names from Repository?

$ sudo dnf search samba

samba.x86_64 : Server and Client software to interoperate with Windows machines
============================================== Name & Summary Matched: samba ==================
samba-libs.i686 : Samba libraries
samba-libs.x86_64 : Samba libraries
samba-winbind.x86_64 : Samba winbind
samba-client.x86_64 : Samba client programs
python3-samba.i686 : Samba Python3 libraries
python3-samba.x86_64 : Samba Python3 libraries
samba-client-libs.i686 : Samba client libraries
samba-client-libs.x86_64 : Samba client libraries
python3-samba-test.x86_64 : Samba Python libraries
samba-winbind-clients.x86_64 : Samba winbind clients
samba-winbind-modules.i686 : Samba winbind modules
samba-winbind-modules.x86_64 : Samba winbind modules
samba-winbind-krb5-locator.x86_64 : Samba winbind krb5 locator
samba-test.x86_64 : Testing tools for Samba servers and clients
samba-common-tools.x86_64 : Tools for Samba servers and clients
ipa-client-samba.x86_64 : Tools to configure Samba on IPA client
samba-common.noarch : Files used by both Samba servers and clients
pcp-pmda-samba.x86_64 : Performance Co-Pilot (PCP) metrics for Samba
samba-krb5-printing.x86_64 : Samba CUPS backend for printing with Kerberos
samba-common-libs.x86_64 : Libraries used by both Samba servers and clients
samba-test-libs.x86_64 : Libraries need by the testing tools for Samba servers and clients
================================================================ Name Matched: samba ============
samba-pidl.noarch : Perl IDL compiler
=============================================================== Summary Matched: samba ==========
ctdb.x86_64 : A Clustered Database based on Samba's Trivial Database (TDB)


This ‘search’ sub-command is very useful to find the package name, for example, if we don’t know the package name of a particular service, then you can use the above command to get the full package name. In our example, we are going to find the package name for the samba service.
15. How to find the package name and file path?


This is one of the greatest features in dnf sub-command. Using the following command, we can find which package owns a file. In this example, we will find the package name of the useradd.

$ sudo dnf provides */useradd

shadow-utils-2:4.6-8.el8.x86_64 : Utilities for managing accounts and shadow
                                : password files
Repo        : @System
Matched from:
Filename    : /etc/default/useradd
Filename    : /usr/sbin/useradd

shadow-utils-2:4.6-8.el8.x86_64 : Utilities for managing accounts and shadow
                                : password files
Repo        : BaseOS
Matched from:
Filename    : /etc/default/useradd
Filename    : /usr/sbin/useradd


In the above output, we can see the package name, file path, repository details.
16. How to upgrade the system (specific or minimal or full) to the latest package versions?


We have multiple options to upgrade our system to the latest version. For example, to upgrade a specific package or with minimal-upgrades like bugfix, enhancement, security-related fix, or an entire system upgrade. To update our system, we can use either upgrade or update command, both commands can provide the same results, but there is a small difference in each command. The upgrade command will erase all the absolute packages while updating the system, whereas the update command doesn’t.

$ sudo dnf upgrade unzip.x86_64

Dependencies resolved.
 Package                 Architecture       Version          Repository       Size
 unzip                   x86_64             6.0-43.el8       BaseOS           195 k

Transaction Summary
Upgrade  1 Package

Total download size: 195 k
Is this ok [y/N]: y


Using the above command, we can upgrade only a specific package. In our example, I have upgraded the “unzip” package to the latest version. OR if you want to get the latest updates on bugfix, enhancement security issues related fix, then use the following command.

$ sudo dnf upgrade “minimal-upgrade”


If you want to upgrade the entire system to the latest version, use the following command.

$ sudo dnf upgrade


The following command is also similar to the above ‘upgrade’ sub-command. It will synchronize existing packages to the latest version.

$ dnf distro-sync

17. How to downgrade a specific package?

$ sudo dnf downgrade package-name [version number]


To downgrade a specific package to the earlier stage, we need to provide the old version number of the package.
18. How to view the dnf repository information?

$ sudo dnf repolist


repo id           repo name                     status
AppStream         CentOS-8 - AppStream          4,933
BaseOS            CentOS-8 - Base               1,673
extras            CentOS-8 - Extras             20


Using the above command we can list only the enabled dnf repositories. By default, DNF will hide all the disabled repositories. To view the list of both (enabled and disabled) repositories, use ‘all’ argument.

$ sudo dnf repolist all

epo id                     repo name                         status
AppStream                  CentOS-8 - AppStream              enabled: 4,933
AppStream-source           CentOS-8 - AppStream Sources      disabled
BaseOS                     CentOS-8 - Base                   enabled: 1,673
BaseOS-source              CentOS-8 - BaseOS Sources         disabled
HighAvailability           CentOS-8 - HA                     disabled
cr                         CentOS-8 - cr                     disabled
extras                     CentOS-8 - Extras                 enabled:    20
19. How to view the transaction history of DNF?

$ sudo dnf history

ID     | Command line             | Date and time    | Action(s)      | Altered
    14 | install wget             | 2020-07-13 11:28 | Install        |    1   
    13 | remove wget-1.19.5-8.el8 | 2020-07-13 11:27 | Removed        |    1   
    12 | upgrade wget.x86_64      | 2020-07-13 11:18 | Upgrade        |    1   
    11 | upgrade tcpdump          | 2020-07-13 09:11 | Upgrade        |    1   
    10 | upgrade unzip.x86_64     | 2020-07-13 09:02 | Upgrade        |    1   
     9 | reinstall vsftpd         | 2020-07-10 17:27 | R              |    2   
     8 | install vsftpd           | 2020-07-10 17:10 | Install        |    1  < 7 | install vsftpd | 2020-07-10 16:11 | Install | 1 > 
     6 | remove vsftpd            | 2020-07-10 16:05 | Removed        |    1   
     5 | install vsftpd           | 2020-07-10 15:24 | Install        |    1   
     4 | remove vsftpd            | 2020-07-10 15:24 | Removed        |    1   
     3 | update sudo -y           | 2020-07-09 14:43 | Upgrade        |    1   
     2 | install vsftpd           | 2020-07-09 14:28 | Install        |    1   
     1 |                          | 2020-06-21 18:19 | Install        | 1348 EE


The DNF history command will provide a complete list of the recent twenty transactions that have been performed in the system. It will help us to understand the overall picture of the package management information like installed, removed, upgrade, rollback packages. Always the latest transaction history appeared at the top of this list. We can use the following command to know more details about a particular transaction. In the above list so far we have completed only 14 transactions to this system. Let us check the details of the transaction ID 14, as shown below:

$ sudo dnf history info 14

Transaction ID : 14
Begin time     : Monday 13 July 2020 11:28:43 AM IST
Begin rpmdb    : 1331:ff1a9c5ee60280c35a854915fecf8ffe805d6a43
End time       : Monday 13 July 2020 11:28:44 AM IST (1 seconds)
End rpmdb      : 1332:4e8d791ac05740b57ba4f15f8bfe469c306944ea
User           : linuxteck 
Return-Code    : Success
Releasever     : 8
Command Line   : install wget
Packages Altered:
    Install wget-1.19.5-8.el8_1.1.x86_64 @AppStream


The transaction ID number 14 was used to install the wget package. Now, if we want, we can undo this particular transaction as it will remove the wget package from the system.

$ sudo dnf history undo 14

Undoing transaction 14, from Monday 13 July 2020 11:28:43 AM IST
    Install wget-1.19.5-8.el8_1.1.x86_64 @AppStream
Dependencies resolved.
 Package                Architecture        Version                 Repository           Size
 wget                   x86_64              1.19.5-8.el8_1.1        @AppStream           2.9 M

Transaction Summary
Remove  1 Package

Freed space: 2.9 M
Is this ok [y/N]: y


Now we can install back the package again by using ‘redo’ sub-command.

$ sudo dnf history redo 14

Repeating transaction 14, from Monday 13 July 2020 11:28:43 AM IST
    Install wget-1.19.5-8.el8_1.1.x86_64 @AppStream
 Package                Architecture        Version                 Repository           Size
 wget                   x86_64              1.19.5-8.el8_1.1        AppStream           735 k

Transaction Summary
Install  1 Package

Total download size: 735 k
Installed size: 2.9 M
Is this ok [y/N]: y
20. How to get the help option of DNF in the command line?

$ man dnf


$ info dnf


$ dnf help


Use one of the above commands to get the help options of dnf command.

Thank you! I hope this article will help you to understand the ‘dnf’ command with examples. Drop me your feedback/comments. If you like this article, kindly share it and it may help others as well.

Few dnf references are collected from this site

Thank you!

About John Gomez

John Britto Founder & Cheif-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 10+ years of experience in Linux and Open Source technologies.

View all posts by John Gomez →

Leave a Reply

Your email address will not be published. Required fields are marked *