Managing Red Hat packages with yum and dnf

REDHATCENTOSLINUXYUMLPIC-1

These commands are tested on CentOS 7.

This is the file where the repository is listed.

# less /etc/yum.conf

The repository files under the following directory are also included with the repositories in the file above:

# ls /etc/yum.repos.d/

yum automatically updates repository information when you issues commands, so you don't have to do it manually.

If for some reason, you need to reinstall a package, just change the install subcommand to reinstall. Example: yum reinstall iotop

It will avoid asking for confirmation:

# yum -y install iotop

If it says that the package is "available" it means that it is not installed. Otherwise it will say "Installed":

# yum list iotop

(Verify the package is installed)

Clear the cache:

# yum clean all

Update a package:

# yum update iotop

To update all installed packages on your system use the command yum update with no package specified.

To remove a package:

# yum remove iotop

# yum list iotop

Another way of checking whether a package is installed and having more information about the package:

# yum info iotop

Check the dependencies:

# yum deplist iotop

Determining what file on your system belongs to what package is easy to just use the provides sub command.

# which top

# yum provides /bin/top

(It returns the full name of the package and repository information)

# yum search [pattern]

These commands are tested on CentOS 7, but newer versions use "dnf" instead. For most commands is just replacing "yum" by "dnf".

Action YUM (CentOS 7) DNF (CentOS 8+ / RHEL 8+)

Install yum install iotop dnf install iotop

Remove yum remove iotop dnf remove iotop

Search yum search iotop dnf search iotop

Update yum update/upgrade dnf update/upgrade *

Clean Cache yum clean all dnf clean all

Info yum info iotop dnf info iotop

Notes: * update vs upgrade in yum/dnf

Command Behavior

yum update Updates packages, keeps obsolete packages

yum upgrade Updates packages, removes obsolete packages (equivalent to yum -- obsoletes update)

dnf update Alias for dnf upgrade — they are identical in dnf

dnf upgrade Updates packages and removes obsoletes

So in dnf, the distinction disappears: update and upgrade do the same thing. Red Hat kept update as an alias purely for backward compatibility with yum habits.

What's correct for LPIC-1?

The exam covers both yum (for older RHEL/CentOS) and dnf (current default). You should know:

  • yum update — the classic command, still valid on systems using yum

  • dnf upgrade — the semantically correct modern command (though dnf update works identically)

For exam purposes, either dnf update or dnf upgrade would be accepted as correct for current systems. But if the question asks about the preferred or canonical dnf command, dnf upgrade is the right answer since that's what the man page documents as the primary command.

More on Red Hat packages here.

Contact

Email

hello@unixtips.eu

© 2025. All rights reserved.