dnf

A new generation of RPM package manager

Supplementary instructions

DNF is a new generation of rpm package manager. It first appeared in the Fedora 18 release. Recently, it replaced yum and officially became the package manager of Fedora 22.

DNF package manager overcomes some bottlenecks of YUM package manager and improves many aspects including user experience, memory usage, dependency analysis, running speed, etc. DNF uses RPM, libsolv and hawkey libraries for package management operations. Although it does not come pre-installed in CentOS and RHEL 7, you can use DNF alongside YUM.

The latest stable release version number of DNF is 1.0, and the release date is May 11, 2015. This version of the DNF package manager (including all versions before it) is mostly written in Python and released under the GPL v2 license.

Install DNF package manager

DNF is not installed by default on RHEL or CentOS 7 systems, but Fedora 22 already uses DNF by default.

Execute the following commands on the system:

yum install epel-release

or

yum install epel-release -y

In fact, there is no reason to force the use of "-y" here. On the contrary, without using "-y", users can check what has been installed into the system during the installation process. But for users who don't have this need, you can use the "-y" parameter in YUM to install everything automatically.

yum install dnf

Then, the DNF package manager is successfully installed on your system. Next, it’s time to start our tutorial! In this tutorial, you will learn 27 commands for the DNF package manager. Using these commands, you can manage RPM packages in your system conveniently and effectively. Now, let's start learning the 27 common commands of the DNF package manager!

View DNF package manager version

Usage: This command is used to view the version of the DNF package manager installed on your system

dnf –version

!Check-DNF-Version

View DNF software libraries available on the system

Purpose: This command is used to display the DNF software libraries available in the system

dnf repolist

View all DNF software libraries available and unavailable in the system

Purpose: This command is used to display all DNF software libraries available and unavailable in the system

dnf repolist all

List all RPM packages

Usage: This command is used to list all available software packages from the software library on the user's system and all software packages that have been installed on the system.

dnf list

List all installed RPM packages

Usage: This command is used to list all installed RPM packages

dnf list installed

List all RPM packages available for installation

Usage: This command is used to list packages available for installation from all available software repositories.

dnf list available

Search for RPM packages in software repositories

Usage: When you don't know the exact name of the software you want to install, you can use this command to search for software packages. You need to type part of the software name after the "search" parameter to search. (In this example we use "nano")

dnf search nano

Find the provider of a file

Usage: You can use this command when you want to see which software package provides a certain file in the system. (In this example, we will look for the provider of the file "/bin/bash")

dnf provides /bin/bash

View package details

Use: This command can help you when you want to view detailed information about a software package before installing it. (In this example, we will look at the details of the package "nano")

dnf info nano

Install package

Usage: Using this command, the system will automatically install the corresponding software and all its required dependencies (in this example, we will use this command to install the nano software)

dnf install nano

Upgrade software package

Purpose: This command is used to upgrade a specified software package (in this example, we will use the command to upgrade the "systemd" software package)

dnf update systemd

Check for updates to system packages

Usage: This command is used to check the updates of all software packages in the system

dnf check-update

Upgrade all system packages

Purpose: This command is used to upgrade all software packages in the system that have available upgrades.

dnf update or dnf upgrade

Remove package

Usage: Delete the specified software package in the system (in this example we will use the command to delete the "nano" software package)

dnf remove nano or dnf erase nano

Remove useless orphaned packages

Use: When no software relies on them anymore, certain software packages used to solve specific software dependencies will become meaningless. This command is used to automatically remove these useless orphan software packages.

dnf autoremove

Delete cached useless packages

Use: In the process of using DNF, various outdated files and unfinished compilation projects will remain in the system for various reasons. We can use this command to delete these useless junk files.

dnf clean all

Get help on using a command

Usage: This command is used to get help on the use of a certain command (including the parameters that can be used for the command and the purpose of the command) (in this example we will use the command to get help on the use of the command "clean")

dnf help clean

See all DNF commands and their uses

Purpose: This command is used to list all DNF commands and their uses

dnf help

View the execution history of DNF commands

Usage: You can use this command to view the execution history of DNF commands on your system. This way you can know what software has been installed and uninstalled since you started using DNF.

dnf history

View all package groups

Usage: This command is used to list all software package groups

dnf grouplist

Install a package group

Usage: This command is used to install a software package group (in this example, we will use the command to install the "Educational Software" package group)

dnf groupinstall ‘Educational Software’

Upgrade packages in a package group

Purpose: This command is used to upgrade software packages in a software package group (in this example, we will use the command to upgrade the software in the "Educational Software" software package group)

dnf groupupdate ‘Educational Software’

Delete a package group

Usage: This command is used to delete a software package group (in this example, we will use the command to delete the "Educational Software" software package group)

dnf groupremove ‘Educational Software’

Install specific software from specific package repositories

Usage: This command is used to install specific software from a specific package repository (in this example we will use the command to install the phpmyadmin package from the package repository epel)

dnf –enablerepo=epel install phpmyadmin

Update packages to the latest stable release

Usage: This command can update all installed software packages to the latest stable release through all available software sources

dnf distro-sync

Reinstall specific packages

Usage: This command is used to reinstall a specific software package (in this example, we will use the command to reinstall the "nano" software package)

dnf reinstall nano

Rollback a version of a specific software

Usage: This command is used to lower the version of a specific package (if possible) (in this example, we will use the command to lower the version of the "acpid" package)

dnf downgrade acpid

Sample output:

Using metadata from Wed May 20 12:44:59 2015
No match for available package: acpid-2.0.19-5.el7.x86_64
Error: Nothing to do.

Original author's note: When executing this command, DNF did not downgrade the specified software ("acpid") as I expected. The issue has been reported.

Summarize

The DNF package manager is an upgraded replacement for the YUM package manager that automates more operations. But in my opinion, because of this, the DNF package manager will not be very popular among experienced Linux system administrators. Examples are as follows: