Six helpful dnf/yum commands to manage software on Red Hat

In RHEL and distros like it, you can install and manage software with yum and dnf. Use them to find packages, see what’s inside and install.

In Red Hat Enterprise Linux and its related distributions (like Fedora and Rocky Linux), YUM and DNF are used to install, manage and remove software. These distros use packages in the RPM format (unlike Ubuntu/Debian which use apt)

So in RHEL or Fedora, this means you’ll often be using the yum or dnf commands to install and manage software on your system.

yum is the same as dnf!

In recent versions of Linux, yum is the same as dnf! In fact, the yum command is just a symbolic link to dnf.

I can check this on my Fedora 36 system. This example output shows that /usr/bin/yum is just a link to the dnf-3 command:

$ ls -la /usr/bin/yum 
lrwxrwxrwx. 1 root root 5 Sep  9 14:49 /usr/bin/yum -> dnf-3

Now let’s look at six dnf (or yum!) commands which you can use to install and manage software on Fedora or Red Hat Enterprise Linux.

Search for a package

Most of the time, when you want to install some software on Linux, the best place to look is the default repositories. Software in your distro’s repositories is usually tailored for your Linux distribution; it installs files in the right places, creates a system service and so on.

On Fedora, you’ll usually have the fedora and updates repositories enabled by default, which both contain lots of packages.

RHEL is an “enterprise” Linux distribution, has far fewer packages in its default repositories, and those are often a little more behind the “cutting-edge”, but they are generally stable and safe to install.

You can search for software in the default repositories using dnf search, for example:

dnf search nginx

This will search for packages containing the string nginx.

Install a package from a repository

When you’ve browsed the search results and decided which package you want to install, you can use the dnf install command. This will look in repositories for a package with the exact name, and install it.

For example, to install nginx:

dnf install nginx

Don’t forget you’ll need superuser privileges to install software, so add “sudo” to the front of the command.

Install a local rpm file

Some software isn’t distributed in repositories, but is distributed as a .rpm file instead. You can sometimes encounter this if you’re installing some commercial, closed-source software. Or, some open source projects might provide a .rpm file on their download or GitHub Releases page.

Whichever way you acquire a .rpm file, you can install it with rpm using the same install command:

dnf install your-rpm-file.rpm

You can also install an RPM file directly from a URL!:

dnf install

List all installed packages

Another common task is to find out all of the packages which are installed on your system, and their versions. This allows you you see all of the software applications which you have installed.

Why might you want to know this?

Sometimes you might want to check if a system has been configured correctly… or perhaps you’re wondering why a particular command is missing?

Here’s the command you need to show all installed packages:

dnf list --installed

The output from this command will show you the package name, the version, and which repository it was installed from (e.g. @fedora, @updates, etc.)

Packages which have been installed from a file are usually shown as coming from the @System repository.

Search for a specific installed package

Searching for a specific installed package? Well, for extra points, you can also pipe this command into grep, which will let you search for all installed packages which match a string.

For example, if I want to see all the podman packages on my system:

[[email protected] ~]$ dnf list --installed | grep podman
podman.x86_64                                        4:4.2.0-2.fc36                      @updates                             
podman-compose.noarch                                1.0.3-6.fc36                        @updates                             
podman-gvproxy.x86_64                                4:4.2.0-2.fc36                      @updates                             
podman-plugins.x86_64                                4:4.2.0-2.fc36                      @updates             

Zingggg! ✨

Which files are included in a package?

Before you install a package, you can find out what’s contained inside it. The massively useful thing about packages is that they install files to a specific location. So you can see, upfront, exactly what will be installed, and where.

So, to find out which files and paths are included in a package:

dnf repoquery -l nginx

The output from this command shows you all of the files in a package, and their paths.

Where does everything go? You’ll often see that application binaries will be installed into /usr/bin, the manpages will be added into /usr/share/man and the program’s config files will go into /etc/.

Which packages provide a command?

If you know you need a command, but you’re not sure which package provides that command, then you can use dnf provides to query the repositories.

For example, when I wanted to install kubectl (for working with Kubernetes), I wasn’t sure which package I needed to install. So I searched like this:

dnf provides /usr/bin/kubectl

… and the result told me that the package which contains kubectl is kubernetes-client (which is in the Fedora repositories, but might not be in the RHEL repositories).

If you’re not exactly sure of the path to the command, you can search with a wildcard:

dnf provides "*/bin/top"

Wrapping up

There are tons more commands you can use to manage packages on your Linux system, but these ones are very handy to know! To find out more, type man dnf.

Useful links:

Tom Donohue

By Tom Donohue, Editor | Twitter | LinkedIn

Tom is the founder of Tutorial Works. He’s an engineer and open source advocate. He uses the blog as a vehicle for sharing tutorials, writing about technology and talking about himself in the third person. His very first computer was an Acorn Electron.

Join the discussion

Got some thoughts on what you've just read? Want to know what other people think? Or is there anything technically wrong with the article? (We'd love to know so that we can correct it!) Join the conversation and leave a comment.

Comments are moderated.