In this article, we’ll consider the YUM package manager that allows to manage program (RPM packages) installation, removal and updating, automatically resolve dependencies and manage additional repositories. This article will be useful for the beginning Linux administrators as a yum cheat sheet.
Yum (Yellowdog Updater Modified) is a console package manager for Linux distros based on RPM packages (RedHat Package Manager). These include such popular OSs like RedHat, CentOS, Fedora, Oracle Linux, Scientific Linux.
Installing, Updating and Removing Packages using YUM
What to start with? Like in any other cases, let’s start with the help:
yum help – the full help on yum
I will highlight the most popular yum commands:
yum clean all – cleans the cache of all packages (usually used if any issues with yum occur)
yum makecache – recreates the package cache
yum repolist – displays the list of all connected repositories, the output looks like this:
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: * extras: * updates: repo id repo name status base/7/x86_64 CentOS-7 - Base 10,019 extras/7/x86_64 CentOS-7 - Extras 435 updates/7/x86_64 CentOS-7 - Updates 2,500 repolist: 12,954
I have only standard CentOS 7 repositories installed on my system: Base, Extras and Updates.
yum list available – displays the list of all packages available for installation.
yum list installed – shows the list of all packages installed in the system.
yum list kernel – displays the list of packages related to the Linux kernel.
You can check if a specific package is installed on your CentOS server (for example, check the apache package status):
yum list installed httpd
Installed Packages httpd.x86_64 2.4.6-89.el7.centos.1 @updates
You can get a detailed information about a specific package. For example, let’s get more info about the MariaDB package:
yum info mariadb
To install a package,
yum install is used. To install the apache web server, run this command:
yum install httpd
Before installing a package, you can check its dependencies using the command:
yum deplist httpd
If you want to install a package, but you have forgotten its full name, you can use the
* wildcard. For example:
yum install epel-*
Resolving Dependencies --> Running transaction check ---> Package epel-release.noarch 0:7-11 will be installed --> Finished Dependency Resolution Install 1 Package Total download size: 15 k Installed size: 24 k Is this ok [y/d/N]:
If you just enter:
yum install epel
No package epel available. Error: Nothing to do
You won’t see any package available.
Yum can install multiple packages at once:
yum install httpd php wget rsyslog
To reinstall a package:
yum reinstall proftpd
To remove an installed package with yum, the remove parameter is used:
yum remove httpd
Before you remove any package, it is recommended to check its dependencies (there are packages that cause the removal of some other packages when you try to remove them).
yum deplist proftpd
To find a package by its name or description:
yum search nginx
Using the provides option, you can find packages containing the specific file. For example, look for the Squid proxy package:
yum provides */squid.conf
To update all installed packages, run this command:
You can update a package by its name:
yum update php
You can check if there are any available updates for your system with the following command:
To get information about available security updates:
yum updateinfo list security
In some cases, issues may occur after you have updated a package or a service. For example, your site has stopped working after you had updated php version. You can roll back to the previous package version using yum:
yum downgrade php
You can also use the group installation of packages with grouplist. There are some predefined package groups with different program sets in the repository. You can display the list of these groups:
Let’s see how it works on the example of the “Basic Web Server” list. To learn more about the group and its packages:
yum groupinfo "Basic Web Server"
After the check we see that the set of packages and services for a web server will be installed.
Here is another useful group list – “System Administration Tools”:
yum groupinfo "System Administration Tools”
As you can see, the list contains the monitoring and debugging tools.
You can install the group list using this command:
yum groupinstall "System Administration Tools"
The installed packages will appear in a separate block (“Installed Groups”):
Using YUN History Command
You can display the yum installation history (the list of transactions) using:
yum history list
The output consists of 5 columns, the first one shows the transaction ID you can use to view the transaction details (installed packages, dependencies).
yum history info 10
Moreover, you can undo the transaction using the command:
yum history undo 10
In my case, 4 packages would have been removed:
You can view the information about yum package installation/removal in /var/log/yum.log:
Useful YUM Command Options
Yum has some useful options you may often need to manage packages. Use -y option to suppress all yum output except for errors. For example:
yum update -y yum install httpd -y
To say no to the request, use this option:
To use yum without any plugins or disable one of them, use the parameters:
To enable a disabled plugin:
To use a disabled repo:
yum update –enablerepo=atomic
To disable a specific repository in yum:
yum update –disablerepo=atomic
YUM Configuration File /etc/yum.conf
The YUM configuration file is
The main config file parameters are:
- cachedir– a local package cache (by default, /var/cache/yum)
- logfile— the path to yum log file
- obsoletes — whether to update obsolete packages (1 — yes, 0 — no)
- gpgcheck — verify the package before the installation (1 — yes, 0 — no)
- keepcache — whether to keep cache (1 — yes, 0 — no)
- cachedir — the directory to store the yum cache (by default, /var/cache/yum)
- debuglevel – the debug level 1-10
- plugins —enable yum plugins (1 — yes, 0 — no)
- bugtracker_url – the link to where yum errors will be registered
- installonly_limit – the maximum number of versions that may be installed for one package
Useful YUM Plugins
Why do you need plugins in yum? Like everywhere, they make our work easier.
Here are some popular plugins and their description:
yum-plugin-fastestmirror – measures the mirror speed and offers the fastest one to install packages.
yum-plugin-security — provides the list of security updates only.
yum-plugin-keys — allows using the keys, keys-info, keys-data, keys-remove parameters
The directory where all plugins are stored is /etc/yum/.
yum-plugin-versionlock – prevents selected packages from updating
To display the list of available yum plugins, run this command:
yum search yum-plugin
======================================================================= N/S matched: yum-plugin ======================================================================= PackageKit-yum-plugin.x86_64 : Tell PackageKit to check for updates when yum exits fusioninventory-agent-yum-plugin.noarch : Ask FusionInventory agent to send an inventory when yum exits kabi-yum-plugins.noarch : The CentOS Linux kernel ABI yum plugin yum-plugin-aliases.noarch : Yum plugin to enable aliases filters yum-plugin-auto-update-debug-info.noarch : Yum plugin to enable automatic updates to installed debuginfo packages yum-plugin-changelog.noarch : Yum plugin for viewing package changelogs before/after updating yum-plugin-copr.noarch : Yum plugin to add copr command yum-plugin-fastestmirror.noarch : Yum plugin which chooses fastest repository from a mirrorlist yum-plugin-filter-data.noarch : Yum plugin to list filter based on package data yum-plugin-fs-snapshot.noarch : Yum plugin to automatically snapshot your filesystems during updates yum-plugin-keys.noarch : Yum plugin to deal with signing keys yum-plugin-list-data.noarch : Yum plugin to list aggregate package data yum-plugin-local.noarch : Yum plugin to automatically manage a local repo. of downloaded packages yum-plugin-merge-conf.noarch : Yum plugin to merge configuration changes when installing packages yum-plugin-ovl.noarch : Yum plugin to work around overlayfs issues yum-plugin-post-transaction-actions.noarch : Yum plugin to run arbitrary commands when certain pkgs are acted on yum-plugin-pre-transaction-actions.noarch : Yum plugin to run arbitrary commands when certain pkgs are acted on yum-plugin-priorities.noarch : plugin to give priorities to packages from different repos yum-plugin-protectbase.noarch : Yum plugin to protect packages from certain repositories. yum-plugin-ps.noarch : Yum plugin to look at processes, with respect to packages yum-plugin-remove-with-leaves.noarch : Yum plugin to remove dependencies which are no longer used because of a removal yum-plugin-rpm-warm-cache.noarch : Yum plugin to access the rpmdb files early to warm up access to the db yum-plugin-show-leaves.noarch : Yum plugin which shows newly installed leaf packages yum-plugin-tmprepo.noarch : Yum plugin to add temporary repositories yum-plugin-tsflags.noarch : Yum plugin to add tsflags by a commandline option yum-plugin-upgrade-helper.noarch : Yum plugin to help upgrades to the next distribution version yum-plugin-verify.noarch : Yum plugin to add verify command, and options yum-plugin-versionlock.noarch : Yum plugin to lock specified packages from being updated
You can install the plugin using
yum install like any other package:
yum install yum-plugin-changelog
yum -y install yum-versionlock
To block updating a package using the plugin, run the following command:
yum versionlock nginx
To display the list of blocked packages:
yum versionlock list
To remove a package from the blocked list:
yum versionlock delete nginx
If you do not want to use a plugin, you can disable it by adding the following option to yum command:
Or you can disable all yum plugins:
How to Configure Proxy for YUM?
Yum is using HTTP/1.1 protocol to interact with the package repositories. If your Linux server can access Internet only through the HTTP proxy server, you can specify the name of the proxy server in the
[main] section of your /etc/yum.conf file:
If your proxy server requires authentication, add the lines as well:
To make sure yum works through a proxy server, use this command:
yum clean all && yum search nginx
To check it, I have specified a German public proxy server address, and the fastestmirror plugin triggered during the installation and it found the mirrors with the fastest speed:
If you want to use proxy only for some repositories, you do not need to make changes to /etc/yum.conf file. You can specify proxy server settings in the repository configuration file /etc/yum.repos.d/your_config.repo instead.
So we have considered basic features of yum, the RPM package manager, in Linux CentOS/ RHEL. In the next article, we will show how to manage YUM/DNF repositories in more detail.