Table of Contents
Introduction to Yum Command
Yum, the command is a package manager used to manage RPM packages in Linux servers. YUM is known as “Yellowdog Updater Modified” it has several options with arguments to search, install, remove and update the packages. They are used across only (RPM) RedHat based operating system like Fedora, Red Hat, CentOS, Oracle Linux and Scientific Linux. Now let us start to run yum command with option and arguments to perform some installations.
Adding “-y” with yum command will not prompt by asking “[y/d/N]” during installing, removing or Updating.
Related Article to YUM
Using AppStream with yum in Red Hat Enterprise Linux 8
The listing, Installing and Removing
Let start with searching for anyone of the package.
# yum search httpd
List all the packages, only specific package using its name, or list all available packages.
# yum list
# yum list httpd
# yum list available
At first, Before installing it’s a good practice to know about some information by using “info” option.
# yum info httpd
Now let us try to install two packages in a single go.
# yum install httpd nc -y
In case we may be required to re-install any package we don’t need to remove and install. Instead, we can perform a re-install.
# yum reinstall httpd -y
In some case you don’t require “nc” instead you need “telnet” this can be accomplished by using “swap” command, this will remove the nc and install the telnet.
# yum swap nc telnet -y
By running “repolist” will print only the enabled repos, to list all repository use “repolist all” this Which will print the status enabled or disabled. Even we can list only the enabled repos.
# yum repolist
# yum repolist all
# yum repolist enabled
To remove a package from the server we can use with “remove” or “erase”.
# yum remove httpd
# yum erase httpd
Enabling the Yum repository
To enable anyone of repository we need to use “yum-config-manager”, In case if this command not available in your minimal installation make sure to install with “yum-utils” package.
# yum-config-manager --enable fasttrack
# yum repolist all
# yum-config-manager --disable fasttrack
# yum repolist all
Working with Yum groups
To print the “Available Environment Groups” and all available Groups.
Available environment groups: This is group consists of a group of packages define how the server needs to be built, it can be Web Server, Minimal installation or server with the graphical interface.
Available Groups: This group consists of all other groups of software like “Development Tools” or “System Administration Tools”.
# yum groups
Printing all available groups with the respective group name.
# yum grouplist
Once we know the group name we should mention the group name inside a double quote to gather info, install or remove.
# yum groupinfo "Security Tools"
# yum groupinstall "Security Tools"
# yum groupremove "Security Tools"
Checking for Update, Upgrade and Downgrade
To Check the local RPM database for any problems use the “check” option.
# yum check
Use the command check-update to do a dry run without updating any packages.
# yum check-update
Running update command will update all the packages in your server.
# yum update -y
Anyone of the specific packages needs to be upgraded we can use upgrade by following package name.
# yum upgrade httpd -y
Rollback anyone of the package to the previous version.
# yum downgrade httpd -y
Listing dependencies and finding features
While installing a package it may require several dependencies, If we need to know the dependencies use “deplist”.
# yum deplist httpd
We don’t know how the /tmp file system was created, or example “nc” command was not available in the server. To know the package name which makes available them we can use “provides” option.
# yum provides /tmp
Download RPM without installing
To download an “RPM” package without installing it. While using this command it will save the package under default location “/var/cache/yum/x86_64/7/base/packages“.
# yum install --downloadonly httpd
In some case, if we need to save under any custom location provide the destination using “–downloaddir” option.
# yum install --downloadonly --downloaddir="/root" httpd
Installing a downloaded Package
To install a downloaded package use “localinstall” option
# yum localinstall httpd-2.4.6-80.0.1.el7.x86_64.rpm
Even we can use rpm command to perform the same.
Working with Yum cache
To cache the metadata for the available repository.
# yum makecache
Whenever we are installing any packages it will not clear after the downloading and installing it. Without clearing the space it will consume more space under “/var/cache/yum/” We need to clear them using the “clean” option or manually removing them.
# yum clean packages
To clear the Yum expired caches
# yum clean expire-cache
There are a lot of caches involved in Yum like, dbcache, rpmdb, plugins, metadata and packages. We have a handy command to clear all above in a single go by running.
# yum clean all
Using Yum Shell
Yum package manager has its own Shell, running all yum command from the shell is possible. Only we need to type the options and argument as shown below. Once all actions are
# yum shell
Working with Yum History
Listing out all YUM used history. The output of this command will provide which user Installed, removed or updated some package using yum.
# yum history
- ID of yum history output.
- Which user performed the installation or upgrade.
- Date and time when they have performed the installation.
- What action they have done, Whether install, update or remove.
- The number of packages affected during the action.
In the above screenshot of “yum history” we need to rollback by choosing any one of an ID, let us rollback ID “8“.
# yum history undo 8
There are several security options available under the yum command. This will be very helpful while we patch the servers to find and apply the right advisory and bug fixes will cover this topic in the next upcoming guide.
Using Man pages
We have covered most of the useful common day to day required commands in this article, however, if you need to read more its good to scroll through man pages using anyone of below three methods.
# yum man
# yum help
# yum --help
To know all man pages related to “yum” use
# man -k yum
This will list out all the related man pages of yum command.
That’s it we have almost covered all useful yum command and its options will cover more topics related to yum in feature posts.
To perform any installation using yum repository we need to be familiar with it, going through all above command with option will make sure you are good with yum command. Subscribe to our newsletter to receive updates and provide your feedback in the comment section.