What is DNF?
DNF (Dandified Yum) is the next generation of the yum (Yellowdog Update Modified) package manager. DNF was created as an improvement to the yum package manager, addressing performance, memory and dependency resolution issues. It is intended that DNF will eventually replace the yum package manager that is currently found on RPM based systems. On RHEL based systems, you can still use "yum" commands, however, these are only links to the newer DNF command.
DNF Command Examples
Below are some examples of using DNF to install, remove, update packages on your Linux system.
Display DNF Version
Basic Syntax: dnf --version
# dnf --version
4.2.23
Installed: dnf-0:4.2.23-4.el8.noarch at Mon 05 Apr 2021 13:25:49 GMT
Built : CentOS Buildsys at Tue 04 Aug 2020 18:52:03 GMT
Installed: rpm-0:4.14.3-4.el8.x86_64 at Mon 05 Apr 2021 13:25:13 GMT
Built : CentOS Buildsys at Tue 21 Jul 2020 17:36:08 GMT
The above command is used to display the currently installed version of DNF.
Displaying Repositories - dnf repolist
Basic Syntax: dnf repolist
# dnf repolist
repo id repo name
appstream CentOS Linux 8 - AppStream
baseos CentOS Linux 8 - BaseOS
extras CentOS Linux 8 - Extras
The command "dnf repolist" will display all enabled repositories. You may pass an additional parameter of "all" to display enabled and disabled repositories.
Listing Installed Packages - dnf list installed
Basic Syntax: dnf list installed
# dnf list installed
Installed Packages
NetworkManager.x86_64 1:1.26.0-12.el8_3 @baseos
NetworkManager-libnm.x86_64 1:1.26.0-12.el8_3 @baseos
NetworkManager-team.x86_64 1:1.26.0-12.el8_3 @baseos
NetworkManager-tui.x86_64 1:1.26.0-12.el8_3 @baseos
acl.x86_64 2.2.53-1.el8 @anaconda
adcli.x86_64 0.8.2-7.el8 @anaconda
at.x86_64 3.1.20-11.el8 @anaconda
attr.x86_64 2.4.48-3.el8 @anaconda
audit.x86_64 3.0-0.17.20191104git1c2f876.el8 @anaconda
audit-libs.x86_64 3.0-0.17.20191104git1c2f876.el8 @anaconda
authselect.x86_64 1.2.1-2.el8 @anaconda
authselect-libs.x86_64 1.2.1-2.el8 @anaconda
avahi-libs.x86_64 0.7-19.el8 @anaconda
basesystem.noarch 11-5.el8 @anaconda
bash.x86_64 4.4.19-12.el8 @anaconda
bash-completion.noarch 1:2.7-5.el8 @anaconda
This command will display all installed packages on your system. The above output is only an extract of the information displayed.
Displaying Available and Installed packages - dnf list
Basic Syntax: dnf list
# dnf list
Last metadata expiration check: 0:02:05 ago on Fri 07 May 2021 11:55:24 BST.
Installed Packages
NetworkManager.x86_64 1:1.26.0-12.el8_3 @baseos
NetworkManager-libnm.x86_64 1:1.26.0-12.el8_3 @baseos
NetworkManager-team.x86_64 1:1.26.0-12.el8_3 @baseos
NetworkManager-tui.x86_64 1:1.26.0-12.el8_3 @baseos
acl.x86_64 2.2.53-1.el8 @anaconda
adcli.x86_64 0.8.2-7.el8 @anaconda
at.x86_64 3.1.20-11.el8 @anaconda
attr.x86_64 2.4.48-3.el8 @anaconda
audit.x86_64 3.0-0.17.20191104git1c2f876.el8 @anaconda
audit-libs.x86_64 3.0-0.17.20191104git1c2f876.el8 @anaconda
authselect.x86_64 1.2.1-2.el8 @anaconda
authselect-libs.x86_64 1.2.1-2.el8 @anaconda
avahi-libs.x86_64 0.7-19.el8 @anaconda
basesystem.noarch 11-5.el8 @anaconda
In the above example, we can see both "Installed Packages" and "Available Packages". (The above output is an extract of the full output).
Display Available packages only - dnf list available
Basic Syntax: dnf list available
# dnf list available
Last metadata expiration check: 0:05:14 ago on Fri 07 May 2021 11:55:24 BST.
Available Packages
CUnit.i686 2.1.3-17.el8 appstream
CUnit.x86_64 2.1.3-17.el8 appstream
GConf2.i686 3.2.6-22.el8 appstream
GConf2.x86_64 3.2.6-22.el8 appstream
HdrHistogram.noarch 2.1.11-2.module_el8.2.0+460+6583c1d0 appstream
HdrHistogram-javadoc.noarch 2.1.11-2.module_el8.2.0+460+6583c1d0 appstream
HdrHistogram_c.i686 0.9.13-2.el8 appstream
HdrHistogram_c.x86_64 0.9.13-2.el8 appstream
Judy.x86_64 1.0.5-18.module_el8.3.0+757+d382997d appstream
LibRaw.i686 0.19.5-2.el8 appstream
LibRaw.x86_64 0.19.5-2.el8 appstream
In the above example we used the "dnf list available" command to list only available packages.
Display Package Information - dnf info
Basic Syntax: dnf info package name
# dnf info nmap
Last metadata expiration check: 0:15:45 ago on Fri 07 May 2021 11:55:24 BST.
Available Packages
Name : nmap
Epoch : 2
Version : 7.70
Release : 5.el8
Architecture : x86_64
Size : 5.8 M
Source : nmap-7.70-5.el8.src.rpm
Repository : appstream
Summary : Network exploration tool and security scanner
URL : http://nmap.org/
License : Nmap
Description : Nmap is a utility for network exploration or security auditing.
The above command displays information about the specified package. Release/version and architecture information. A link is also available to the main package website.
Searching for a package - dnf search
Basic Syntax: dnf search pattern
# dnf search bash
Last metadata expiration check: 0:19:12 ago on Fri 07 May 2021 11:55:24 BST.
========================== Name Exactly Matched: bash ==========================
bash.x86_64 : The GNU Bourne Again shell
========================= Name & Summary Matched: bash =========================
bash-completion.noarch : Programmable completion for Bash
bash-doc.x86_64 : Documentation files for bash
libguestfs-bash-completion.noarch : Bash tab-completion scripts for libguestfs
: tools
libvirt-bash-completion.x86_64 : Bash completion script
nbdkit-bash-completion.noarch : Bash tab-completion for nbdkit
pcp-pmda-bash.x86_64 : Performance Co-Pilot (PCP) metrics for the Bash shell
============================ Summary Matched: bash =============================
python3-argcomplete.noarch : Bash tab completion for argparse
In the above example we searched for any packages that contained the pattern "bash". This option is useful if you do not know the full name of the package. This option searches package metadata for the specified keywords.
dnf provides
Basic Syntax: dnf provides provide-spec
The above command displays what package provides the specified file.
# dnf provides netstat
Last metadata expiration check: 0:22:26 ago on Fri 07 May 2021 11:55:24 BST.
net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools
Repo : @System
Matched from:
Filename : /usr/bin/netstat
net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools
Repo : baseos
Matched from:
Filename : /usr/bin/netstat
In the above example, we were looking to find out which package provides the utility "netstat". The command "dnf provides netstat" was issued. The resulting output indicated that "netstat" is available as part of the "net-tools" package.
Installing Packages - dnf install
Basic Syntax: dnf install package name
The "dnf install" command is used to install the specified package. Any dependencies are displayed and then installed for the specified package.
# dnf install net-tools
Last metadata expiration check: 0:26:06 ago on Fri 07 May 2021 11:55:24 BST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing:
net-tools x86_64 2.0-0.52.20160912git.el8 baseos 322 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 322 k
Installed size: 942 k
Is this ok [y/N]: y
Downloading Packages:
net-tools-2.0-0.52.20160912git.el8.x86_64.rpm 1.2 MB/s | 322 kB 00:00
--------------------------------------------------------------------------------
Total 463 kB/s | 322 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.52.20160912git.el8.x86_64 1/1
Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Verifying : net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Installed:
net-tools-2.0-0.52.20160912git.el8.x86_64
Complete!
Reinstalling a Package - dnf reinstall
Basic Syntax: dnf reinstall package-name
The "dnf reinstall" command is used to reinstall the specified package.
# dnf reinstall net-tools
Last metadata expiration check: 0:28:03 ago on Fri 07 May 2021 11:55:24 BST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Reinstalling:
net-tools x86_64 2.0-0.52.20160912git.el8 baseos 322 k
Transaction Summary
================================================================================
Total download size: 322 k
Installed size: 942 k
Is this ok [y/N]: y
Downloading Packages:
net-tools-2.0-0.52.20160912git.el8.x86_64.rpm 1.3 MB/s | 322 kB 00:00
--------------------------------------------------------------------------------
Total 535 kB/s | 322 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Reinstalling : net-tools-2.0-0.52.20160912git.el8.x86_64 1/2
Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 1/2
Cleanup : net-tools-2.0-0.52.20160912git.el8.x86_64 2/2
Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 2/2
Verifying : net-tools-2.0-0.52.20160912git.el8.x86_64 1/2
Verifying : net-tools-2.0-0.52.20160912git.el8.x86_64 2/2
Reinstalled:
net-tools-2.0-0.52.20160912git.el8.x86_64
Complete!
Updating specific packages - dnf update
Basic Syntax: dnf update package-name
The "dnf update" command is used to update a specific package. Before using the update option, it is useful to check the current version of the package and check to see whether a newer version is available. To do this we use the "dnf list" command to show the currently installed version and any versions that are available.
# dnf list zip.x86_64
Last metadata expiration check performed 0:46:26 ago on Tue Oct 27 09:51:50 2015.
Installed Packages
zip.x86_64 3.0-13.fc22 @System
Available Packages
zip.x86_64 3.0-14.fc22 updates
From the above output we can see that the package "zip.X86_64" is at version "3.0-13.fc22" and an updated version "3.0-14.fc22" is available. To update this package, we use the "dnf update" command:
# dnf update zip.x86_64
Last metadata expiration check performed 0:49:37 ago on Tue Oct 27 09:51:50 2015.
Dependencies resolved.
=================================================================================
Package Arch Version Repository Size
=================================================================================
Upgrading:
zip x86_64 3.0-14.fc22 updates 267 k
Transaction Summary
=================================================================================
Upgrade 1 Package
Total download size: 267 k
Is this ok [y/N]: y
Downloading Packages:
zip-3.0-14.fc22.x86_64.rpm 951 kB/s | 267 kB 00:00
---------------------------------------------------------------------------------
Total 163 kB/s | 267 kB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Upgrading : zip-3.0-14.fc22.x86_64 1/2
Cleanup : zip-3.0-13.fc22.x86_64 2/2
Verifying : zip-3.0-14.fc22.x86_64 1/2
Verifying : zip-3.0-13.fc22.x86_64 2/2
Upgraded:
zip.x86_64 3.0-14.fc22
Complete!
Downgrading a Package - dnf downgrade
Basic Syntax: dnf downgrade package-name
The "dnf downgrade" command is used to downgrade the specified packages to the highest of all known lower versions if possible. In the following example, we will downgrade the previously updated package "zip.x86_64". To establish the current version of the package we used the command "dnf list".
# dnf list zip.x86_64
Last metadata expiration check performed 0:10:01 ago on Tue Oct 27 11:18:12 2015.
Installed Packages
zip.x86_64 3.0-14.fc22 @updates
# dnf downgrade zip.x86_64
Last metadata expiration check performed 0:10:10 ago on Tue Oct 27 11:18:12 2015.
Dependencies resolved.
=================================================================================
Package Arch Version Repository Size
=================================================================================
Downgrading:
zip x86_64 3.0-13.fc22 fedora 267 k
Transaction Summary
=================================================================================
Downgrade 1 Package
Total download size: 267 k
Is this ok [y/N]: y
Downloading Packages:
zip-3.0-13.fc22.x86_64.rpm 843 kB/s | 267 kB 00:00
---------------------------------------------------------------------------------
Total 252 kB/s | 267 kB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Downgrading : zip-3.0-13.fc22.x86_64 1/2
Erasing : zip-3.0-14.fc22.x86_64 2/2
Verifying : zip-3.0-13.fc22.x86_64 1/2
Verifying : zip-3.0-14.fc22.x86_64 2/2
Downgraded:
zip.x86_64 3.0-13.fc22
Complete!
Removing a Package - dnf remove
Basic Syntax: dnf remove package-name
The "dnf remove" command is used to remove a specified package. You may also use the "erase" option, however, "erase" has now been deprecated.
# dnf remove net-tools
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
net-tools x86_64 2.0-0.52.20160912git.el8 @baseos 942 k
Transaction Summary
================================================================================
Remove 1 Package
Freed space: 942 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Erasing : net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Running scriptlet: net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Verifying : net-tools-2.0-0.52.20160912git.el8.x86_64 1/1
Removed:
net-tools-2.0-0.52.20160912git.el8.x86_64
Complete!
Checking for system updates - dnf check-update
Basic Syntax: dnf check-update
The "dnf check-update" command is used to check for available updates on your Linux system. The "check-update" checks for any available updates of the specified packages. If no package name(s) are given then it will check for all updates available to your system. (Below is a small extract from the "dnf check-update" command).
# dnf check-update
Last metadata expiration check performed 0:54:40 ago on Tue Oct 27 09:51:50 2015.
NetworkManager.x86_64 1:1.0.6-6.fc22 updates
NetworkManager-libnm.x86_64 1:1.0.6-6.fc22 updates
PackageKit.x86_64 1.0.10-1.fc22 updates
PackageKit-glib.x86_64 1.0.10-1.fc22 updates
abrt.x86_64 2.6.1-5.fc22 updates
Listing Available Updates - dnf list updates
Basic Syntax: dnf list updates
The "dnf list updates" command is used to list any available updates available to your system. Can be used as an alternative to the above "check-update" command. (Below is a small extract from the output).
Last metadata expiration check performed 0:56:17 ago on Tue Oct 27 09:51:50 2015.
Upgraded Packages
NetworkManager.x86_64 1:1.0.6-6.fc22 updates
NetworkManager-libnm.x86_64 1:1.0.6-6.fc22 updates
PackageKit.x86_64 1.0.10-1.fc22 updates
PackageKit-glib.x86_64 1.0.10-1.fc22 updates
abrt.x86_64 2.6.1-5.fc22 updates
abrt-addon-ccpp.x86_64 2.6.1-5.fc22 updates
Update all Packages - dnf update
Basic Syntax: dnf update
The "dnf update" command is used to update all packages on your system. Individual packages may be specified. Where no packages are specified, all packages will be updated providing newer packages are available. (Below is a small extract of output from the "update" command.
# dnf update
Last metadata expiration check performed 0:58:50 ago on Tue Oct 27 09:51:50 2015.
Dependencies resolved.
================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
abrt-dbus x86_64 2.6.1-5.fc22 updates 127 k
audit-libs-python x86_64 2.4.4-1.fc22 updates 96 k
dnf-langpacks-conf noarch 0.15.1-1.fc22 updates 12 k
tcpdump x86_64 14:4.7.4-2.fc22 updates 407 k
tzdata noarch 2015g-1.fc22 updates 422 k
uboot-tools x86_64 2015.07-5.fc22 updates 271 k
udisks2 x86_64 2.1.6-1.fc22 updates 333 k
unzip x86_64 6.0-22.fc22 updates 174 k
util-linux x86_64 2.26.2-3.fc22 updates 2.0 M
vim-minimal x86_64 2:7.4.827-1.fc22 updates 465 k
xdg-utils noarch 1.1.1-1.fc22 updates 82 k
xfsprogs x86_64 3.2.2-2.fc22 updates 873 k
Transaction Summary
================================================================================
Install 22 Packages
Upgrade 306 Packages
Total download size: 227 M
Is this ok [y/N]:y
Tidying Up - dnf autoremove
Basic Syntax: dnf autoremove
The "dnf autoremove" command is used to removes all "leaf" packages from the your system that were originally installed as dependencies of user-installed packages but which are no longer required by any such package. Any packages that can be removed will be displayed. You will be required to confirm the removal of the packages.
# dnf autoremove
Last metadata expiration check: 0:51:10 ago on Fri 07 May 2021 11:55:24 BST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Removing:
grub2-tools-efi x86_64 1:2.02-90.el8_3.1 @baseos 2.0 M
Transaction Summary
================================================================================
Remove 1 Package
Freed space: 2.0 M
Is this ok [y/N]:
Working with Package Groups - dnf grouplist
Many packages are grouped together into convenient groups. This allows a system administrator to install a group of packages with one single command. The command "dnf grouplist" can be used to display available groups on your system. (Below is an extract of the "grouplist" command).
# dnf grouplist
Last metadata expiration check: 0:53:44 ago on Fri 07 May 2021 11:55:24 BST.
Available Environment Groups:
Server with GUI
Server
Workstation
Virtualization Host
Custom Operating System
Installed Environment Groups:
Minimal Install
Available Groups:
Container Management
.NET Core Development
RPM Development Tools
Development Tools
Graphical Administration Tools
Headless Management
Legacy UNIX Compatibility
Network Servers
Scientific Support
Security Tools
Smart Card Support
System Tools
Install a Group of Packages - dnf groupinstall groupname
In the example below we are going to install the "System Tools" group packages. To install all the "System Tools" package, we issue the command: dnf groupinstall "System Tools". (Please note, if the group package contains spaces within its name, then you must place quotes around the group name.)
Below is an extract from the output from the "groupinstall" command.
# dnf groupinstall "System Tools"
Last metadata expiration check: 0:55:49 ago on Fri 07 May 2021 11:55:24 BST.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing group/module packages:
NetworkManager-libreswan x86_64 1.2.10-4.el8 appstream 120 k
cifs-utils x86_64 6.8-3.el8 baseos 96 k
libreswan x86_64 3.32-7.el8_3 appstream 1.4 M
nmap x86_64 2:7.70-5.el8 appstream 5.8 M
openldap-clients x86_64 2.4.46-15.el8 baseos 202 k
samba-client x86_64 4.12.3-12.el8.3 baseos 692 k
setserial x86_64 2.17-45.el8 baseos 32 k
tigervnc x86_64 1.10.1-9.el8_3 appstream 290 k
tmux x86_64 2.7-1.el8 baseos 317 k
xdelta x86_64 3.1.0-4.el8 baseos 96 k
zsh x86_64 5.5.1-6.el8_1.2 baseos 2.9 M
Installing dependencies:
fltk x86_64 1.3.4-5.el8 appstream 590 k
fontconfig x86_64 2.13.1-3.el8 baseos 275 k
hicolor-icon-theme noarch 0.17-2.el8 appstream 49 k
keyutils x86_64 1.5.10-6.el8 baseos 63 k
ldns x86_64 1.7.0-21.el8 appstream 166 k
libICE x86_64 1.0.9-15.el8 appstream 74 k
libSM x86_64 1.2.3-1.el8 appstream 48 k
libX11 x86_64 1.6.8-3.el8 appstream 611 k
libX11-common noarch 1.6.8-3.el8 appstream 158 k
Installing Groups:
System Tools
Transaction Summary
================================================================================
Install 63 Packages
Total download size: 26 M
Installed size: 80 M
Is this ok [y/N]:
Update a Group of Packages - dnf groupupdate groupname
In the example below we are going to update all packages within the group "System Tools". In this example, no updates were installed as we are already fully up to date.
# dnf groupupdate "System Tools"
Last metadata expiration check: 1:00:55 ago on Fri 07 May 2021 11:55:24 BST.
Dependencies resolved.
================================================================================
Package Architecture Version Repository Size
================================================================================
Installing Groups:
System Tools
Transaction Summary
================================================================================
Is this ok [y/N]: y
Complete!
Remove a Group of Packages - dnf groupremove groupname
In the example below we are going to remove a group. To remove the group "System Tools", the command: dnf groupremove "System Tools" is used. (Please note, if the group package contains spaces within its name, then you must place quotes around the group name).
Note, the output below is only an extract of the full output.
# dnf groupremove "System Tools"
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
NetworkManager-libreswan x86_64 1.2.10-4.el8 @appstream 420 k
cifs-utils x86_64 6.8-3.el8 @baseos 192 k
libreswan x86_64 3.32-7.el8_3 @appstream 4.7 M
nmap x86_64 2:7.70-5.el8 @appstream 24 M
openldap-clients x86_64 2.4.46-15.el8 @baseos 612 k
samba-client x86_64 4.12.3-12.el8.3 @baseos 2.3 M
setserial x86_64 2.17-45.el8 @baseos 37 k
tigervnc x86_64 1.10.1-9.el8_3 @appstream 849 k
tmux x86_64 2.7-1.el8 @baseos 781 k
xdelta x86_64 3.1.0-4.el8 @baseos 184 k
zsh x86_64 5.5.1-6.el8_1.2 @baseos 7.2 M
Removing unused dependencies:
............
............
perl-constant noarch 1.33-396.el8 @baseos 26 k
perl-interpreter x86_64 4:5.26.3-416.el8 @baseos 14 M
perl-libs x86_64 4:5.26.3-416.el8 @baseos 5.8 M
perl-macros x86_64 4:5.26.3-416.el8 @baseos 5.1 k
perl-parent noarch 1:0.237-1.el8 @baseos 9.0 k
perl-threads x86_64 1:2.21-2.el8 @baseos 107 k
perl-threads-shared x86_64 1.58-2.el8 @baseos 76 k
tigervnc-icons noarch 1.10.1-9.el8_3 @appstream 33 k
tigervnc-license noarch 1.10.1-9.el8_3 @appstream 18 k
unbound-libs x86_64 1.7.3-14.el8 @appstream 1.3 M
Removing Groups:
System Tools
Transaction Summary
================================================================================
Remove 63 Packages
Freed space: 80 M
Is this ok [y/N]: y
Synchronise All Packages - dnf distro-sync
"dnf distro-sync" will upgrade or downgrade all packages to the latest versions that are available from any enabled repository.
# dnf distro-sync
Last metadata expiration check: 1:08:00 ago on Fri 07 May 2021 11:55:24 BST.
Dependencies resolved.
Nothing to do.
Complete!
In the above example, no packages needed to be upgraded or downgraded.
Clean temporary Files - dnf clean
Basic Syntax: dnf clean option
The "dnf clean" command is used to perform a clean-up of temporary files for any currently enabled repositories on your Linux system. Various options are available to carry out specific functions. "dnf clean all" will carry out all of the options.
dnf clean dbcache
Removes cache files generated from the repository metadata. This forces DNF to regenerate the cache files the next time it is run.
dnf clean expire-cache
Removes local cookie files saying when the metadata and mirrorlists were downloaded for each repo. DNF will re-validate the cache for each repo the next time it is used.
dnf clean metadata
Removes repository metadata. Those are the files which DNF uses to determine the remote availability of packages. Using this option will make DNF download all the metadata the next time it is run.
dnf clean packages
Removes any cached packages from the system.
dnf clean plugins
Tells all enabled plugins to eliminate their cached data.
dnf clean all
Carries out all of the above.
# dnf clean all
23 files removed
Displaying Transaction History
Basic Syntax: dnf history
The "dnf history" command is used to display transactions that have happened in the past.
# dnf history
ID | Command line | Date and time | Action(s) | Altered
--------------------------------------------------------------------------------
18 | groupremove System Tools | 2021-05-07 13:00 | Removed | 64
17 | groupupdate System Tools | 2021-05-07 12:56 | Install | 1
16 | groupinstall System Tools | 2021-05-07 12:55 | Install | 64
15 | remove net-tools | 2021-05-07 12:31 | Removed | 1
14 | reinstall net-tools | 2021-05-07 12:23 | R | 2
13 | install net-tools | 2021-05-07 12:21 | Install | 1
12 | remove net-tools | 2021-05-07 12:21 | Removed | 1
11 | reinstall net-tools | 2021-05-06 20:21 | R | 2
10 | install net-tools | 2021-05-06 20:17 | Install | 1
9 | remove net-tools | 2021-05-06 20:16 | Removed | 1
8 | remove nmap | 2021-05-06 19:21 | Removed | 2
7 | install nmap | 2021-05-06 19:16 | Install | 2
6 | update | 2021-05-06 19:12 | Upgrade | 2
5 | install pcp-system-tools | 2021-04-25 11:11 | Install | 16
4 | update | 2021-04-25 11:05 | I, U | 77 EE
3 | install iptraf-ng | 2021-04-24 19:32 | Install | 1
2 | install wget | 2021-04-24 13:48 | Install | 1
1 | | 2021-04-05 14:23 | Install | 447 EE
DNF Information - dnf history info
Basic Syntax: dnf history info ID
The "dnf history info ID" command is used to display what transactions were actually carried out on your system. The output from the "dnf history" command will show an "ID" number in the first column. This number is used to obtain information relating to that transaction.
For example, if we wanted to find out details of "ID 7", we would issue the command: yum history info 7".
# yum history info 7
Transaction ID : 7
Begin time : Thu 06 May 2021 19:16:36 BST
Begin rpmdb : 470:90a69471d69beece85331af7c03515de544d9166
End time : Thu 06 May 2021 19:16:37 BST (1 seconds)
End rpmdb : 472:23aa6606ab163229f864599cd7e100b11e698c31
User : John
Return-Code : Success
Releasever : 8
Command Line : install nmap
Comment :
Packages Altered:
Install nmap-2:7.70-5.el8.x86_64 @appstream
Install nmap-ncat-2:7.70-5.el8.x86_64 @appstream
From the above we can see that the user "john" successfully installed a package called "nmap".
Getting Help with DNF
Basic Syntax: dnf help command
The "dnf help" command is used to display a list of available commands. You may also specify a command after the "help" option to display specific information. Below are some examples of the "dnf help" command in use. For full details of the options available to the "dnf" command, you can consult the man pages for dnf by issuing the command "man dnf". Another useful command is "man yum2dnf". This man page displays the differences between the "yum" package manager and "dnf".
Examples:
dnf help install
# dnf help install
install PACKAGE...
Install a package or packages on your system
dnf help remove
# dnf help remove
remove PACKAGE...
Remove a package or packages from your system
alias: erase