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

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

--y

Assume no for all prompts

--assumeno

Disable GPG verification

--nogpgcheck

Skip broken packages

Skips packages that whose dependencies can’t be resolved.

--skip-broken

Enable/Disable repository

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

--disable-repo=[path]
--enable-repo=[path]

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
xorg-x11-apps-0:7.7-6.el7.x86_64

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

$ sudo yum info [package-name]

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; # install yumdownloader

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]

More

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.

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.

Conclusion

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?

similar to /etc/apt/sources.list you have files that define from what repositories packages can be downloaded

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
[bareos_bareos-16.2]
name=bareos bareos-16.2 (CentOS_7)
type=rpm-md
baseurl=http://download.bareos.org/bareos/release/16.2/CentOS_7/
gpgcheck=1
gpgkey=http://download.bareos.org/bareos/release/16.2/CentOS_7/repodata/repomd.xml.key
enabled=1

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.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
admin