DNF Commands for RPM Package Management in Fedora Linux

In this article, we are going to learn ‘DNF Commands for RPM Package Management in Fedora Linux’. DNF is a software package manager that installs, updates, and removes packages in RPM-based Linux distributions. It automatically computes dependencies and determines the actions necessary to install packages. Using RNP makes it easy to retain groups of DNF machines by eliminating the need to manually update the individual.

DNF or Dandified Yum is the next-generation version of Yum. It keeps CLI compatibility with Yum and defines rigid API for extensions and plugins. Plugins can enhance or extend the features of the DNF or provide additional CLI commands at the top of the above If you know the name of such a command (along with bold commands) you can find/install the package which uses proper virtualization (as a <aka >>) where <ulias> is the name of the command eg. dnf-command for repoquery command (typical command applies to specify dependencies of the required packages).

 Features Of DNF Package Manager:

  • Easy configuration
  • Support for multiple repositories
  • Fast and low memory-centric operations
  • Dependency calculation based on modern dep solving technology
  • Package Group Support, with Multi-Repository Groups
  • Rpm-compatible behavior
  • Documented, Solid Python API
  • Easy interface
  • The DNF runs in Python 2 and Python 3
DNF Commands for RPM Package Management in Fedora Linux
DNF Commands for RPM Package Management in Fedora Linux

Follow the below Article For DNF Commands for RPM Package Management in Fedora Linux:

Installation of DNF:

mangesh@localhost ~]$ sudo yum install dnf
[sudo] password for mangesh: 
Last metadata expiration check: 0:03:18 ago on Sun 07 Jul 2019 07:32:40 PM IST.
Package dnf-4.2.2-2.fc30.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!

Getting DNF Help:

1)Check DNF Version:

Check the version of the DNF installed on your system.

mangesh@localhost ~]$ dnf --version
4.2.2
  Installed: dnf-0:4.2.2-2.fc30.noarch at Fri 26 Apr 2019 02:27:04 AM GMT
  Built    : Fedora Project at Fri 05 Apr 2019 11:32:21 AM GMT

  Installed: rpm-0:4.14.2.1-4.fc30.1.x86_64 at Fri 26 Apr 2019 02:25:15 AM GMT
  Built    : Fedora Project at Sat 02 Feb 2019 06:46:11 PM GMT

2)List all DNF Commands and Options:

All the available dnf commands to help list and options just to type.

[mangesh@localhost ~]$ dnf help
usage: dnf [options] COMMAND

List of Main Commands:

alias                     List or create command aliases
autoremove                remove all unneeded packages that were originally installed as dependencies
check                     check for problems in the packagedb
check-update              check for available package upgrades
clean                     remove cached data
deplist                   List package's dependencies and what packages provide them
distro-sync               synchronize installed packages to the latest available versions
downgrade                 Downgrade a package
group                     display, or use, the groups information
help                      display a helpful usage message
history                   display, or use, the transaction history
info                      display details about a package or group of packages
install                   install a package or packages on your system
list                      list a package or groups of packages
makecache                 generate the metadata cache
mark                      mark or unmark installed packages as installed by user.
module                    Interact with Modules.
provides                  find what package provides the given value
reinstall                 reinstall a package
remove                    remove a package or packages from your system
repolist                  display the configured software repositories
repoquery                 search for packages matching keyword
repository-packages       run commands on top of all packages in given repository
search                    search package details for the given string
shell                     run an interactive DNF shell
swap                      run an interactive dnf mod for remove and install one spec
updateinfo                display advisories about packages
upgrade                   upgrade a package or packages on your system
upgrade-minimal           upgrade, but only 'newest' package match which fixes a problem that affects your system

List of Plugin Commands:

builddep                  Install build dependencies for package or spec file
changelog                 Show changelog data of packages
config-manager            manage dnf configuration options and repositories
copr                      Interact with Copr repositories.
debug-dump                dump information about installed rpm packages to file
debug-restore             restore packages recorded in debug-dump file
debuginfo-install         install debuginfo packages
download                  Download package to current directory
needs-restarting          determine updated binaries that need restarting
playground                Interact with Playground repository.
repoclosure               Display a list of unresolved dependencies for repositories
repodiff                  List differences between two sets of repositories
repograph                 Output a full package dependency graph in dot format
repomanage                Manage a directory of rpm packages
reposync                  download all packages from remote repo

Optional arguments:
  -c [config file], --config [config file]
                        config file location
  -q, --quiet           quiet operation
  -v, --verbose         verbose operation
  --version             show DNF version and exit
  --installroot [path]  set install root
  --nodocs              do not install documentations
  --noplugins           disable all plugins
  --enableplugin [plugin]
                        enable plugins by name
  --disableplugin [plugin]
                        disable plugins by name
  --releasever RELEASEVER
                        override the value of $releasever in config and repo
                        files
  --setopt SETOPTS      set arbitrary config and repo options
  --skip-broken         resolve depsolve problems by skipping packages
  -h, --help, --help-cmd
                        show command help
  --allowerasing        allow erasing of installed packages to resolve
                        dependencies
  -b, --best            try the best available package versions in
                        transactions.
  --nobest              do not limit the transaction to the best candidate
  -C, --cacheonly       run entirely from system cache, don't update cache
  -R [minutes], --randomwait [minutes]
                        maximum command wait time
  -d [debug level], --debuglevel [debug level]
                        debugging output level
  --debugsolver         dumps detailed solving results into files
  --showduplicates      show duplicates, in repos, in list/search commands
  -e ERRORLEVEL, --errorlevel ERRORLEVEL
                        error output level
  --obsoletes           enables dnf's obsoletes processing logic for upgrade
                        or display capabilities that the package obsoletes for
                        info, list and repoquery
  --rpmverbosity [debug level name]
                        debugging output level for rpm
  -y, --assumeyes       automatically answer yes for all questions
  --assumeno            automatically answer no for all questions
  --enablerepo [repo]
  --disablerepo [repo]
  --repo [repo], --repoid [repo]
                        enable just specific repositories by an id or a glob,
                        can be specified multiple times
  --enable, --set-enabled
                        enable repos with config-manager command
                        (automatically saves)
  --disable, --set-disabled
                        disable repos with config-manager command
                        (automatically saves)
  -x [package], --exclude [package], --excludepkgs [package]
                        exclude packages by name or glob
  --disableexcludes [repo], --disableexcludepkgs [repo]
                        disable excludepkgs
  --repofrompath [repo,path]
                        label and path to additional repository, can be
                        specified multiple times.
  --noautoremove        disable removal of dependencies that are no longer
                        used
  --nogpgcheck          disable gpg signature checking (if RPM policy allows)
  --color COLOR         control whether color is used
  --refresh             set metadata as expired before running the command
  -4                    resolve to IPv4 addresses only
  -6                    resolve to IPv6 addresses only
  --destdir DESTDIR, --downloaddir DESTDIR
                        set directory to copy packages to
  --downloadonly        only download packages
  --comment COMMENT     add a comment to transaction
  --bugfix              Include bugfix relevant packages, in updates
  --enhancement         Include enhancement relevant packages, in updates
  --newpackage          Include newpackage relevant packages, in updates
  --security            Include security relevant packages, in updates
  --advisory ADVISORY, --advisories ADVISORY
                        Include packages needed to fix the given advisory, in
                        updates
  --bz BUGZILLA, --bzs BUGZILLA
                        Include packages needed to fix the given BZ, in
                        updates
  --cve CVES, --cves CVES
                        Include packages needed to fix the given CVE, in
                        updates
  --sec-severity {Critical,Important,Moderate,Low}, --secseverity {Critical,Important,Moderate,Low}
                        Include security relevant packages matching the
                        severity, in updates
  --forcearch ARCH      Force the use of an architecture

DNF Repositories:

1)List Enabled DNF Repositories:

The option ‘repolist’ with the DNF command will display all enabled repositories within your system.

[mangesh@localhost ~]$ sudo dnf repolist
Last metadata expiration check: 0:09:29 ago on Sun 07 Jul 2019 07:32:40 PM IST.
repo id                                  repo name                                                  status
adobe-linux-x86_64                       Adobe Systems Incorporated                                      3
*fedora                                  Fedora 30 - x86_64                                         56,582
*fedora-modular                          Fedora Modular 30 - x86_64                                    135
*updates                                 Fedora 30 - x86_64 - Updates                                9,562
*updates-modular                         Fedora Modular 30 - x86_64 - Updates                          140

 2)List all Enabled and Disabled DNF Repositories:

The option ‘repolist all‘ will print all the enabled/disabled repositories within your system.

mangesh@localhost ~]$ dnf repolist all
Last metadata expiration check: 0:19:38 ago on Sun 07 Jul 2019 07:32:40 PM IST.
repo id                               repo name                                            status
adobe-linux-x86_64                    Adobe Systems Incorporated                           enabled:      3
*fedora                               Fedora 30 - x86_64                                   enabled: 56,582
fedora-cisco-openh264                 Fedora 30 openh264 (From Cisco) - x86_64             disabled
fedora-cisco-openh264-debuginfo       Fedora 30 openh264 (From Cisco) - x86_64 - Debug     disabled
fedora-debuginfo                      Fedora 30 - x86_64 - Debug                           disabled
*fedora-modular                       Fedora Modular 30 - x86_64                           enabled:    135
fedora-modular-debuginfo              Fedora Modular 30 - x86_64 - Debug                   disabled
fedora-modular-source                 Fedora Modular 30 - Source                           disabled
fedora-source                         Fedora 30 - Source                                   disabled
*updates                              Fedora 30 - x86_64 - Updates                         enabled:  9,562
updates-debuginfo                     Fedora 30 - x86_64 - Updates - Debug                 disabled
*updates-modular                      Fedora Modular 30 - x86_64 - Updates                 enabled:    140
updates-modular-debuginfo             Fedora Modular 30 - x86_64 - Updates - Debug         disabled
updates-modular-source                Fedora Modular 30 - Updates Source                   disabled
updates-source                        Fedora 30 - Updates Source                           disabled
updates-testing                       Fedora 30 - x86_64 - Test Updates                    disabled
updates-testing-debuginfo             Fedora 30 - x86_64 - Test Updates Debug              disabled
updates-testing-modular               Fedora Modular 30 - x86_64 - Test Updates            disabled
updates-testing-modular-debuginfo     Fedora Modular 30 - x86_64 - Test Updates Debug      disabled
updates-testing-modular-source        Fedora Modular 30 - Test Updates Source              disabled
updates-testing-source                Fedora 30 - Test Updates Source                      disabled

Listing Packages:

1)List all Available and Installed Packages using DNF:

The command “dnf list” will list all the available packages from all the repositories and installed packages on your Linux system.

[mangesh@localhost ~]$ dnf list

2)List all Installed Packages using DNF:

The “DNF list” command shows all available/installed packages from all repositories. However, you have the option to list only the installed packages using the “List installed” option listed below.

[mangesh@localhost ~]$ dnf list installed

Installed Packages
GConf2.x86_64                          3.2.6-25.fc30            @anaconda       
GeoIP.x86_64                           1.6.12-5.fc30            @anaconda       
GeoIP-GeoLite-data.noarch              2018.06-3.fc30           @anaconda       
LibRaw.x86_64                          0.19.2-3.fc30            @anaconda       
ModemManager.x86_64                    1.10.0-1.fc30            @anaconda       
ModemManager-glib.x86_64               1.10.0-1.fc30            @anaconda       
NetworkManager.x86_64                  1:1.16.0-1.fc30          @anaconda       
NetworkManager-adsl.x86_64             1:1.16.0-1.fc30          @anaconda       
NetworkManager-bluetooth.x86_64        1:1.16.0-1.fc30          @anaconda       
NetworkManager-config-connectivity-fedora.noarch
                                       1:1.16.0-1.fc30          @anaconda       
NetworkManager-libnm.x86_64            1:1.16.0-1.fc30          @anaconda       
NetworkManager-openconnect.x86_64      1.2.4-11.fc30            @anaconda       
NetworkManager-openconnect-gnome.x86_64
                                       1.2.4-11.fc30            @anaconda       
NetworkManager-openvpn.x86_64          1:1.8.10-1.fc30          @anaconda       
NetworkManager-openvpn-gnome.x86_64    1:1.8.10-1.fc30          @anaconda       
NetworkManager-ppp.x86_64              1:1.16.0-1.fc30          @anaconda       
NetworkManager-pptp.x86_64             1:1.2.8-1.fc30.1         @anaconda

3)List all Available Packages using DNF:

The “Available List” option lists all the packages available to install from all enabled repositories.

[mangesh@localhost ~]$ dnf list available
systemtap-runtime-python3.x86_64        4.1-1.fc30                       updates
systemtap-runtime-virtguest.x86_64      4.1-1.fc30                       updates
systemtap-runtime-virthost.x86_64       4.1-1.fc30                       updates
systemtap-sdt-devel.i686                4.1-1.fc30                       updates
systemtap-sdt-devel.x86_64              4.1-1.fc30                       updates
systemtap-server.x86_64                 4.1-1.fc30                       updates
systemtap-testsuite.x86_64              4.1-1.fc30                       updates
sysusage.noarch                         5.7-3.fc30                       fedora 
sysusage-common.noarch                  5.7-3.fc30                       fedora 
sysusage-httpd.noarch                   5.7-3.fc30                       fedora 
sysusage-rsysusage.noarch               5.7-3.fc30                       fedora 
t-digest.noarch                         3.0-9.fc30                       fedora 
t-digest-javadoc.noarch                 3.0-9.fc30                       fedora 
t-prot.noarch                           3.4-8.fc30                       fedora 
t1lib.i686                              5.1.2-24.fc30                    fedora 
t1lib.x86_64                            5.1.2-24.fc30                    fedora 
t1lib-apps.x86_64                       5.1.2-24.fc30                    fedora 
t1lib-devel.i686                        5.1.2-24.fc30                    fedora 
t1lib-devel.x86_64                      5.1.2-24.fc30                    fedora 
t1lib-static.i686                       5.1.2-24.fc30                    fedora 
t1lib-static.x86_64                     5.1.2-24.fc30                    fedora 
t1utils.x86_64                          1.39-9.fc30                      fedora

Updating Packages:

1)Check for System Updates using DNF:

Check for updates to system packages installed in the system.

mangesh@localhost ~]$ dnf check-update
Last metadata expiration check: 0:27:06 ago on Sun 07 Jul 2019 09:20:37 PM IST.

GConf2.x86_64                                3.2.6-26.fc30             updates  
ModemManager.x86_64                          1.10.2-1.fc30             updates  
ModemManager-glib.x86_64                     1.10.2-1.fc30             updates  
NetworkManager.x86_64                        1:1.16.2-1.fc30           updates  
NetworkManager-adsl.x86_64                   1:1.16.2-1.fc30           updates  
NetworkManager-bluetooth.x86_64              1:1.16.2-1.fc30           updates  
NetworkManager-config-connectivity-fedora.noarch
                                             1:1.16.2-1.fc30           updates  
NetworkManager-libnm.x86_64                  1:1.16.2-1.fc30           updates  
NetworkManager-ppp.x86_64                    1:1.16.2-1.fc30           updates  
NetworkManager-ssh.x86_64                    1.2.10-1.fc30             updates  
NetworkManager-ssh-gnome.x86_64              1.2.10-1.fc30             updates  
NetworkManager-team.x86_64                   1:1.16.2-1.fc30           updates  
NetworkManager-wifi.x86_64                   1:1.16.2-1.fc30           updates  
NetworkManager-wwan.x86_64                   1:1.16.2-1.fc30           updates  
SDL.x86_64                                   1.2.15-39.fc30            updates

Or

mangesh@localhost ~]$ dnf list updates

Package Groups:

1)List all Group Package:

The “Dnf grouplist” command will print all the available or installed packages, if it does not mention it, it lists all known groups.

[mangesh@localhost ~]$ dnf grouplist
Last metadata expiration check: 0:35:23 ago on Sun 07 Jul 2019 09:20:37 PM IST.
Available Environment Groups:
   Fedora Custom Operating System
   Minimal Install
   Fedora Server Edition
   Fedora Workstation
   Fedora Cloud Server
   KDE Plasma Workspaces
   Xfce Desktop
   LXDE Desktop
   LXQt Desktop
   Cinnamon Desktop
   MATE Desktop
   Sugar Desktop Environment
   Deepin Desktop
   Development and Creative Workstation
   Web Server
   Infrastructure Server
   Basic Desktop
Installed Groups:
   LibreOffice
Available Groups:
   3D Printing
   Administration Tools
   Audio Production
   Authoring and Publishing
   Books and Guides
   C Development Tools and Libraries
   Cloud Infrastructure
   Cloud Management Tools
   Compiz
   Container Management
   D Development Tools and Libraries
   Design Suite
   Development Tools
   Domain Membership
   Fedora Eclipse
   Editors
   Educational Software
   Electronic Lab
   Engineering and Scientific
   FreeIPA Server
   Games and Entertainment
   Headless Management
   MATE Applications
   Medical Applications
   Milkymist
   Network Servers
   Office/Productivity
   Python Classroom
   Python Science
   Robotics
   RPM Development Tools
   Security Lab
   Sound and Video
   System Tools
   Text-based Internet
   Window Managers

2)Install a Group Package using DNF:

To install a package group, for example, “’Educational Software’”, run:

mangesh@localhost ~]$ sudo dnf groupinstall 'Educational Software'
[sudo] password for mangesh:
Adobe Systems Incorporated 2.6 kB/s | 2.9 kB 00:01
Fedora Modular 30 - x86_64 2.8 kB/s | 6.9 kB 00:02
Fedora Modular 30 - x86_64 - Updates 4.7 kB/s | 6.6 kB 00:01
Fedora 30 - x86_64 - Updates 4.4 kB/s | 6.8 kB 00:01
Fedora 30 - x86_64 4.6 kB/s | 7.0 kB 00:01
Dependencies resolved.
==========================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================
Installing Groups:
Educational Software

Transaction Summary
==========================================================================================================================================

Is this ok [y/N]: y
Complete!

 3)Update a Group Package:

To Update a package group, run the below command.

mangesh@localhost ~]$ sudo dnf groupupdate 'Educational Software'
[sudo] password for mangesh: 
Last metadata expiration check: 0:02:36 ago on Sun 07 Jul 2019 10:01:54 PM IST.
Dependencies resolved.
==========================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================
Installing Groups:
Educational Software

Transaction Summary
==========================================================================================================================================

Is this ok [y/N]: y
Complete!

4)Remove a Group Package:

To remove a package group, run the below command.

mangesh@localhost ~]$ sudo dnf groupremove 'Educational Software'
[sudo] password for mangesh: 
Dependencies resolved.
==========================================================================================================================================
Package Architecture Version Repository Size
==========================================================================================================================================
Removing Groups:
Educational Software

Transaction Summary
==========================================================================================================================================

Is this ok [y/N]: y
Complete!

DNF History:

1)View History of DNF:

Using the “Dnf history” command, we can see all the actions done by the DNF command.

mangesh@localhost ~]$ sudo dnf history
[sudo] password for mangesh: 
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     5 | groupremove Educational  | 2019-07-07 22:08 | Removed        |    1   
     4 | groupupdate Educational  | 2019-07-07 22:04 | Install        |    1   
     3 | groupinstall Educational | 2019-07-07 22:02 | Install        |    1   
     2 | install flash-plugin als | 2019-07-07 14:07 | Install        |    1  <
     1 |                          | 2019-04-26 07:54 | Install        | 1632 >E

Use the following ID to view information about a particular transaction.

[mangesh@localhost ~]$ sudo dnf history list 2
ID | Command line | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
2 | install flash-plugin als | 2019-07-07 14:07 | Install | 1

Cleaning Up:

1)Remove Orphan Packages using DNF:

To remove those orphan packages run the below command.

mangesh@localhost ~]$ sudo dnf autoremove
Last metadata expiration check: 0:46:30 ago on Sun 07 Jul 2019 10:01:54 PM IST.
Dependencies resolved.
Nothing to do.
Complete!

2)Remove Cached Packages using DNF:

Often we encounter headers and incomplete transactions, so there is an error in executing the DNF. We may include remote package information by executing all cached packages and headers.

[mangesh@localhost ~]$ dnf clean all
41 files removed

Also Read – Useful RPM Command With Examples In Linux

That’s all, In this article, we have explained DNF Commands for RPM Package Management in Fedora Linux. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment

Share this:
WhatsApp Channel Join Now
Telegram Channel Join Now
Instagram Channel Join Now

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.