update: 2021-1 yum -> dnf

hostnamectl; # tested on
    Virtualization: kvm
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 5.4.11
      Architecture: x86-64
ll /usr/bin/yum -> dnf-3

all those yum commands still work with dnf (nice work!)

DNF or Dandified YUM[2][3][4] is the next-generation version of the Yellowdog Updater, Modified (yum), a package manager for .rpm-based distributions. DNF was introduced in Fedora 18 in 2013,[5] it has been the default package manager since Fedora 22 in 2015[6] and Red Hat Enterprise Linux 8.[7] (src)


What is yum?

yum is used under CentOS7, Fedora, RedHat RHEL, Oracle).

It’s written in python and it stands for “Yellowdog Updater, Modified”, as it was originally called “yup”, the package manager for Yellow Dog Linux.

In addition to rpm it provides an “App Store” so to speak – the possibility to search an online repository and download and install packages (like apt) from those repositories provided by volunteers (thanks a lot).

it tries to satisfy dependencies automatically. (install additional packages needed by the package that is supposed to be installed)

yum commands are typically run as

yum <command> <package name/s>

By default, yum will automatically attempt to check all configured repositories to resolve all package dependencies during an installation/upgrade.

The following is a list of the most commonly-used yum commands. For a complete list of available yum commands, refer to man yum.

yum install <package name/s>

Used to install the latest version of a package or group of packages. If no package matches the specified package name(s), they are assumed to be a shell glob, and any matches are then installed.

yum update <package name/s>

Used to update the specified packages to the latest available version. If no package name/s are specified, then yum will attempt to update all installed packages. If the –obsoletes option is used (i.e. yum –obsoletes <package name/s>, yum will process obsolete packages. As such, packages that are obsoleted accross updates will be removed and replaced accordingly.

yum check-update
# list all available repositories
yum -v repolist

This command allows you to determine whether any updates are available for your installed packages. (comparable to apt-get update) yum returns a list of all package updates from all repositories if any are available.

yum remove <package name/s>
Used to remove specified packages, along with any other packages dependent on the packages being removed.
yum provides <file name>

Used to determine which packages provide a specific file or feature.

yum search <keyword>

This command is used to find any packages containing the specified keyword in the description, summary, packager and package name fields of RPMs in all repositories.

yum localinstall <absolute path to package name/s>

Used when using yum to install a package located locally in the machine.

src: https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s1-yum-useful-commands.html

Useful flags

Assume yes for all prompts


Assume no for all prompts


Disable GPG verification


Skip broken packages

Skips packages that whose dependencies can’t be resolved.


Enable/Disable repository

You can dynamically enable or disable a repository for a single execution.


Package Management

Installing an RPM package

Installing an RPM package from remote repositories

$ sudo yum install [package-name]

Installing a local RPM package

$ sudo yum install /path/to/vim-1.2.rpm

Installing a specific version of a package

$ sudo yum install gcc-4.0

Removing an RPM package and dependencies

Removes a package and any package it depends on (provided nothing else depends on it).

$ sudo yum remove [package-name]

Note: this will only remove the binaries and libraries, any configuration files will stay intact.

Downgrade a package

This will install the package’s previous version.

$ sudo yum downgrade [package-name]

View a package’s dependencies

$ sudo yum deplist [package-name]

Listing packages

The yum list command can take different arguments:

List all available packages from repositories

$ sudo yum list available

List installed packages

$ sudo yum list installed

List installed and available packages

$ sudo yum list all

List all packages (installed or available) that match a given [package-name], can be a glob

$ sudo yum list [package-name]
$ sudo yum list mysql*

Search for package

This searches for [package-name] across all repositories, also looking inside package descriptions.

$ sudo yum search [package-name]

if that does not return any usefull results try:

# SearchTerm = xclock

yum provides */xclock

repoquery -q -f */xclock

btw: if your xclock is not “ticking” you will need to fire it up via command line/bash with the -update 1 (update every 1seconds) parameter…

Upgrade all system packages

$ sudo yum upgrade

This command installs all of the latest versions of each package installed on the system and is, generally, not recommended to be run on production systems.

Reinstall a single package

Sometimes, it’s necessary to force reinstallation of a package.

$ sudo yum reinstall [package-name]

View info for a package

# get infos about NameOfPackage
yum info NameOfPackage

# get info about package: alternative example:
repoquery -i lvm2.x86_64

Name        : lvm2
Version     : 2.02.180
Release     : 10.el7_6.8
Architecture: x86_64
Size        : 3110931
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Group       : System Environment/Base
URL         : http://sources.redhat.com/lvm2
Repository  : updates
Summary     : Userland logical volume management tools
Source      : lvm2-2.02.180-10.el7_6.8.src.rpm
Description :
LVM2 includes all of the support for handling read/write operations on
physical volumes (hard disks, RAID-Systems, magneto optical, etc.,
multiple devices (MD), see mdadm(8) or even loop devices, see
losetup(8)), creating volume groups (kind of virtual disks) from one
or more physical volumes and creating one or more logical volumes
(kind of logical partitions) in volume groups.

yum info lvm2.x86_64
Installed Packages
Name        : lvm2
Arch        : x86_64
Epoch       : 7
Version     : 2.02.180
Release     : 10.el7_6.8
Size        : 3.0 M
Repo        : installed
From repo   : updates
Summary     : Userland logical volume management tools
URL         : http://sources.redhat.com/lvm2
License     : GPLv2
Description : LVM2 includes all of the support for handling read/write operations on
            : physical volumes (hard disks, RAID-Systems, magneto optical, etc.,
            : multiple devices (MD), see mdadm(8) or even loop devices, see
            : losetup(8)), creating volume groups (kind of virtual disks) from one
            : or more physical volumes and creating one or more logical volumes
            : (kind of logical partitions) in volume groups.

Find which RPM package installs a given file

This command is very handy when it’s not obvious which package needs to be installed to use it.

$ sudo yum provides [file]

yum provides can also take a glob:

$ sudo yum provides "*/bin/vim"

List all dependencies for a given package

$ sudo yum provides [package-name]

Package Groups

Note: yum now has a groups subcommand for group operations, versions before 3.4.x should refer to this document instead.

yum has the concept of “package groups”, groups of related packages that can be installed or uninstalled at once, that don’t necessarily depend on each other.

List all groups

$ sudo yum group list

Install all packages for a group

$ sudo yum group install "Basic Web Server"

Remove all packages for a group

$ sudo yum group remove "Basic Web Server"

Repository Management

List all repositories

$ sudo yum repolist

List all packages for a given [repository]

(Note: yum > 3.4.x only)

$ sudo yum repo-pkgs [repository] list

Install all packages from given [repository]

(Note: yum > 3.4.x only)

$ sudo yum repo-pkgs [repository] install

Remove all packages from a given [repository]

(Note: yum > 3.4.x only)

$ sudo yum repo-pkgs [repository] remove

Update local metadata cache

This is run automatically by yum as needed, but can be refreshed manually with yum makecache

$ sudo yum makecache

When this command is run, all available packages are fetched and re-indexed from the repositories yum knows about.

yum-utils and yumdownloader

In order to download source packages, it’s necessary to install an additional package for yum, called “yum-utils”, which provides a yumdownloader binary, among other things.

yum install yum-utils;

Downloading RPMs

Downloading RPM from remote repositories

$ sudo yumdownloader [package-name

Downloading Source RPMs

$ sudo yumdownloader --source [package-name]
Downloading all dependencies for an RPM
$ sudo yumdownloader --resolve [package-name]

Filtering by architecture

$ sudo yumdownloader --archlist=[arch-list]  [package-name]


yum-utils adds other useful commands to yum that are too specific to cover here but are still worth looking over at the YumUtils website.

what files are in/come with/provided/belong by/to this package?

if manually downloaded

rpm -qlp /path/to/file.rpm

from repository:

repoquery --list lvm2.x86_64

The Future: DNF

DNF is the next generation of package management for redhat based operating systems. Currently, it exists as a fork of yum 3.4 that use libsolv as its dependency solver. It is currently in use by the Fedora distribution.

CentOS8: dnf manpage dnf.man.txt


Getting more familiar with your package manager’s tools can help you be more productive when finding, installing, and querying packages.

We highly recommend that users of production redhat based systems become familiar with yum and dnf.

You can learn more about the tools mentioned in this blog post by reading the man page: man 8 yum

links: https://blog.packagecloud.io/eng/2015/04/05/yum-cheat-sheet/

where are repositories defined?

ll /etc/yum.repos.d

insgesamt 52K
drwxr-xr-x. 2 root root 248 22. Mai 15:03 .
drwxr-xr-x. 112 root root 8,0K 24. Mai 11:38 ..
-rw-r--r--. 1 root root 241 28. Okt 2016 bareos.repo
-rw-r--r--. 1 root root 1,7K 29. Nov 19:12 CentOS-Base.repo
-rw-r--r--. 1 root root 1,3K 29. Nov 19:12 CentOS-CR.repo
-rw-r--r--. 1 root root 649 29. Nov 19:12 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 29. Nov 19:12 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 29. Nov 19:12 CentOS-Media.repo
-rw-r--r--. 1 root root 1,3K 29. Nov 19:12 CentOS-Sources.repo
-rw-r--r--. 1 root root 2,9K 29. Nov 19:12 CentOS-Vault.repo
-rw-r--r--. 1 root root 957 27. Dez 18:37 epel.repo
-rw-r--r--. 1 root root 1,1K 27. Dez 18:37 epel-testing.repo

cat bareos.repo; # display one example file
name=bareos bareos-16.2 (CentOS_7)

cat CentOS-Base.repo; # display one example file

# CentOS-Base.repo
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.

name=CentOS-$releasever - Base

#released updates
name=CentOS-$releasever - Updates

#additional packages that may be useful
name=CentOS-$releasever - Extras

#additional packages that extend functionality of existing packages
name=CentOS-$releasever - Plus

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!