How to install Packages using dnf on RHEL 8

In our previous post, we have discussed about the installation of RHEL 8 beta that has been released for developers and testers. RHEL 8 has a lot of new features, you can check all the major new features here, Talking about Package and software management, RHEL 8 has introduced an advanced and new version of yum that is known as dnf (dandified yum) that offers several advantages like increase in performance, support for modular content is added and has well-designed API for integration with tooling.
DNF is the new upcoming major version of YUM that is used for package management of rhel 7.x based systems. DNF was introduced in Fedora 18 and it is now available in RHEL 8 for managing rpm based packages.

To Search a Package with dnf

To search a Package using dnf use below command. For example to search for nginx that is now available in the base OS repository of RHEL 8
# dnf search nginx

Install a Package with dnf

To install a Package using dnf command, run dnf install followed by the package name, it works similar to yum. You can use -y at the end if you dont want to get the prompt for confirmation. All the dependencies required for the package will be automatically resolved.
# dnf install nginx

Removing a Package with dnf

To remove the installed Package along with its dependencies, run the below command.
# dnf remove nginx

Get info of a Package with dnf

You can get information about a Package using dnf that gives the details about Package like name, version, Arch, Size, repo, URL, license and description.
# dnf info firefox

Check if Update for any Package is available

You can check if any update for any specific package is available using the check-update option, if no package is specified, it will check whether any updates for the system is available.
# dnf check-update <package-specs>

Update Packages with dnf

You can use dnf upgrade to update the package to the latest version available. It also takes care of dependencies as required. In case there is no update available, it will show the message “Nothing to do”
# dnf upgrade <package>

List all the available repositories

using dnf repolist, you can list all the enabled as well as disabled repositories.
# dnf repolist all

Clean dnf cache

Clean performs the cleanup of temporary files kept for repositories. To clean all the cached files from the enabled repositories, run below command regularly to clean up the cache.
# dnf clean all

Group Packages

Group is collection of packages. To install, remove or upgrade group package use options as shown below.

To List all the matching groups

# dnf group list <group-spec>

To install a Group Package

# dnf group install <group-spec>

To remove a Group Package

# dnf group remove <group-spec>

To Display package lists of a Group

# dnf group info <group-spec>

To Upgrade the Group packages

# dnf group upgrade <group-spec>

View History of dnf

To view all the past transactions of dnf, use below command.
# dnf history

You can perform various operations with dnf history like redo, rollback, undo.
# dnf history redo <transaction-spec>
# dnf history rollback <transaction-spec>
# dnf history undo <transaction-spec>

To know what package provides a File

Provides command is useful to find out the package providing a file. In case you know a filename and what to know what package provides that file, use below file.
# dnf provides <provide-spec>

Open an Interactive dnf shell

You can open an interactive dnf shell to conduct multiple commands during a single execution of DNF.

# dnf shell