Yum is known as Red Hat package manager, use to get information about available packages, fetch packages from repositories.
It is also used to install and uninstall packages and update single packages as well as an entire system with the latest available version.
Yum package manager is top-rated in Red Hat-based Linux distribution to install and update packages as it automatically resolves the dependency while install, remove or update packages and install them properly.
Yum having capabilities to be configured with new and additional repositories, source of packages, and having many plug-ins to enhance and extend capabilities of its features.
Yum is competent to perform system administrator task within the time frame, and you can perform your tasks very fast, as it provides capabilities beyond of GUI package management tools.
YUM Package Manager – Check and Update packages
In this section of YUM tutorial, we will learn to check available update and update packages, and also we will learn to upgrade system in off-line mode using Operating system’s ISO files.
Check for update
Using Yum package manager, you can check available update for installed packages in your system, as shown below:
# yum check-update Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca acl.x86_64 2.2.49-7.el6_9.1 base attr.x86_64 2.4.44-7.el6 base audit.x86_64 2.4.5-6.el6 base audit-libs.x86_64 2.4.5-6.el6 base authconfig.x86_64 6.1.12-23.el6 base bash.x86_64 4.1.2-48.el6 base bfa-firmware.noarch 188.8.131.52-2.el6 base bind.x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates
The above output will show you the package name with CPU architecture, version of packages, and repository name where package is available.
First package in above output is:
acl.x86_64 2.2.49-7.el6_9.1 base
acl – the name of the package
X86_64 – the CPU architecture, package built for
2.2.49-7.el6_9.1 – the version of the latest available package for update
base – the repository where the package located
We can use Yum to update kernel, RPM, and YUM themselves and their dependencies.
Yum can update a single package, multiple packages or all packages at once, and if there are any dependencies of the package, Yum will update package, and update available packages for dependencies too.
Update a Single Package
To update a single package run the Yum command with package name as the root user, as shown below:
The syntax for Updating Single package:
# yum update package_name
~]# yum update vim Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Setting up Update Process Resolving Dependencies --> Running transaction check ---> Package vim-enhanced.x86_64 2:7.4.629-5.el6_10.2 set to be updated --> Processing Dependency: vim-common = 2:7.4.629-5.el6_10.2 for package: 2:vim-enhanced-7.4.629-5. el6_10.2.x86_64 --> Running transaction check ---> Package vim-common.x86_64 2:7.4.629-5.el6_10.2 set to be updated --> Finished Dependency Resolution Dependencies Resolved ====================================================================================== Package Arch Version Repository Size ====================================================================================== Updating: vim-enhanced x86_64 2:7.4.629-5.el6_10.2 updates 1.0 M Updating for dependencies: vim-common x86_64 2:7.4.629-5.el6_10.2 updates 6.7 M Transaction Summary ====================================================================================== Install 0 Package(s) Upgrade 2 Package(s)
Yum will present the update information with package name and version including dependencies and then prompts you to ask whether you want to perform the update.
Yum runs in interactive mode by default, If you know the process and transaction going to performed by Yum command you can use -y option with the command to automatically answer Yes to any question asked by Yum while updating packages.
Update all packages and their dependencies
To update all packages and their dependencies in the single command you can use yum update command, as shown below:
# yum update
Update package Automatically
Yum has the capabilities to schedule update process where all packages will get updates automatically.
To schedule automatic update you can use yum-corn package. By using Yum-corn service, you can schedule an automatic update process for your system daily as a cron job.
To install yum-cron use following command:
~]# yum install yum-cron
After installation of yum-cron needs to enable service, by default yum-cron service is disabled. You can enable the service, as shown below:
~]# chkconfig yum-cron on
To start yum-cron service use following command:
~]# service yum-cron start
You can also verify the service status by using the below command:
You can configure yum-cron, edit the file /etc/sysconfig/yum-cron, there are options to configure frequency, and notification alert.
Upgrade system with ISO file and Yum
When your system not connected with internet, you can use Linux installation ISO image file to update system easily and quickly.
You can use the following steps to upgrading Linux System:
Step 1 – Create a directory
Create a directory to mount the ISO image.
# mkdir mount_dir
Generally, we are creating directory under the /media directory.
Step 2 – Mount ISO image
To mount Red Hat ISO image to the previously created target directory. Use below command as the root user:
# mount –o loop iso_name mount_dir
Replace iso_name with the path of ISO image and mount_dir with a path of the target directory. The -o loop option is use to mount the file as a block device.
Step 3 – Create a repository file
You can copy media.repo into directory /etc/yum.repos.d/, you can keep any name for your new repository file, follow below command to create a new repository file.
# cp mount_dir/media.repo /etc/yum.repos.d/new.repo
Step 4 – Configure base URL
Now, you need to configure a new repository file to point Red Hat installation ISO image. Edit baseurl into newly created repository file as shown below:
Replace mount_dir with ISO image mounted directory’s path.
Step 5 – Update all repository
To update all repository source available at /etc/yum.repos.d/ use the following command:
The above command will upgrade your system to the version provided by the mounted ISO image.
Step 6 – Unmount ISO image
After system upgrading successful, you can unmount the ISO image using the following command:
Now, you can remove this directory.
Step 7 – Delete newly created repository
Now, if you don’t require previously created repository for another installation or update, you can delete repository file by using below command:
Upgrading RHEl 7.2 to 7.3
~]# mkdir /media/rhel7 ~]# mount -o loop RHEL7.3-Server-20160130.0-x86_64-DVD1.iso /media/rhel7/ ~]# cp /media/rhel7/media.repo /etc/yum.repos.d/rhel7.repo
Configure baseurl in repository file:
~]# yum update
Now, use following command to unmount and remove the newly created repository:
~]# umount /media/rhel7/ ~]# rmdir /media/rhel7/ ~]# rm /etc/yum.repos.d/rhel7.repo
YUM – Packages and Package Groups
In this section of Yum package manager’s tutorial, we will learn to search, list and display the package information using Yum, and also we will learn to install and remove any packages from the system using Yum.
To search any RPM package on the repository, using the following command:
yum search term…
It will display package name, descriptions, and summaries.
For example, here we searching package vim and emacs as shown below:
~]# yum search vim emacs
The yum search command is very useful to search for information about any packages.
yum search will return matches in package name and summary, which is much faster search then yum search all command but yum search all is more exhaustive search results.
The yum list command gives information about packages, package group, and repositories. It allows as to filter results by appending one or more glob expressions as arguments. The glob expressions are any string contain one or more of the wildcard characters * and ?.
“yum list glob_expression”
The above command will list all installed and available packages matching the glob expression.
For example, here, we list all the ABRT add-ons and plug-ins using glob expression, as shown below:
~]# yum list abrt-addon* abrt-plugin* Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Available Packages abrt-addon-ccpp.x86_64 2.0.8-44.el6.centos base abrt-addon-kerneloops.x86_64 2.0.8-44.el6.centos base abrt-addon-python.x86_64 2.0.8-44.el6.centos base abrt-addon-vmcore.x86_64 2.0.8-44.el6.centos base
“yum list all”
It will list all installed and available packages.
~]# yum list all Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Installed Packages apr.x86_64 1.3.9-5.el6_9.1 @base apr-util.x86_64 1.3.9-3.el6_0.1 @base apr-util-ldap.x86_64 1.3.9-3.el6_0.1 @base attr.x86_64 2.4.44-4.el6 @anacond ORBit2.i686 2.14.17-7.el6 base ORBit2.x86_64 2.14.17-7.el6 base ORBit2-devel.i686 2.14.17-7.el6 base ORBit2-devel.x86_64 2.14.17-7.el6 base OpenEXR.x86_64 1.6.1-8.1.el6 base OpenEXR-devel.i686 1.6.1-8.1.el6 base autofs.x86_64 1:5.0.5-140.el6_10.1 updates bind.x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates bind-chroot.x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates bind-devel.i686 32:9.8.2-0.68.rc1.el6_10.3 updates bind-devel.x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates centos-release-xen.x86_64 10:8-5.el6 extras centos-release-xen-410.x86_64 10:8-5.el6 extras centos-release-xen-44.x86_64 10:8-5.el6 extras centos-release-xen-46.x86_64 10:8-5.el6 extras centos-release-xen-48.x86_64 10:8-5.el6 extras centos-release-xen-common.x86_64 10:8-5.el6 extras
“yum list installed”
It will list all the installed packages on your system with information of package name, version, CPU architecture, and repository from where it was retrieved.
~]# yum list installed "krb?-*" Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Installed Packages krb5-libs.x86_64 1.8.2-3.el6 @anaconda-CentOS-201106060106.x86_64/6.0
“yum list available”
It provides output information similar to yum list installed but print information of packages which are available in all enabled repositories.
~]# yum list available gstreamer*plugin* Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Available Packages gstreamer-plugins-bad-free.i686 0.10.19-5.el6_8 base gstreamer-plugins-bad-free.x86_64 0.10.19-5.el6_8 base gstreamer-plugins-bad-free-devel.i686 0.10.19-5.el6_8 base gstreamer-plugins-bad-free-devel.x86_64 0.10.19-5.el6_8 base gstreamer-plugins-bad-free-devel-docs.x86_64 0.10.19-5.el6_8 base gstreamer-plugins-bad-free-extras.i686 0.10.19-5.el6_8 base gstreamer-plugins-bad-free-extras.x86_64 0.10.19-5.el6_8 base gstreamer-plugins-base.i686 0.10.29-2.el6 base gstreamer-plugins-base.x86_64 0.10.29-2.el6 base gstreamer-plugins-base-devel.i686 0.10.29-2.el6 base gstreamer-plugins-base-devel.x86_64 0.10.29-2.el6 base gstreamer-plugins-base-devel-docs.noarch 0.10.29-2.el6 base gstreamer-plugins-good.i686 0.10.23-4.el6_8 base gstreamer-plugins-good.x86_64 0.10.23-4.el6_8 base gstreamer-plugins-good-devel.i686 0.10.23-4.el6_8 base gstreamer-plugins-good-devel.x86_64 0.10.23-4.el6_8 base
It will list information about all package groups.
~]# yum grouplist Loaded plugins: fastestmirror, presto Setting up Group Process Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca base/group_gz | 242 kB 00:00 Installed Groups: E-mail server FCoE Storage Client Legacy UNIX compatibility Network Infrastructure Server Network file system client PHP Support Perl Support Storage Availability Tools System administration tools Web Server iSCSI Storage Client Available Groups: Additional Development Afrikaans Support Albanian Support Amazigh Support Arabic Support Armenian Support Assamese Support Azerbaijani Support Backup Client Backup Server
The above command will help you to list repository information along with ID and Name of the package for all enabled repositories.
~]# yum repolist Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca repo id repo name status base CentOS-6 - Base 6,713 extras CentOS-6 - Extras 46 updates CentOS-6 - Updates 595 zabbix Zabbix Official Repository - x86_64 185 zabbix-non-supported Zabbix Official Repository non-supported - x86_64 15 repolist: 7,554
Display Package Information
You can use yum command to get the information about one or more packages, as glob expressions are allowed with yum information command.
To get the information about packages, use the following command:
yum info package_name…
For example, to get the information about the postfix package, type:
~]# yum info postfix Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Installed Packages Name : postfix Arch : x86_64 Epoch : 2 Version : 2.6.6 Release : 8.el6 Size : 9.7 M Repo : installed From repo : base Summary : Postfix Mail Transport Agent URL : http://www.postfix.org License : IBM Description: Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL), TLS
You can also pass the query to yum database to get information about package by using following command:
yumdb info package_name
The above command use to get the additional information of package, including the checksum of the package.
For example, you can use the below command to get additional information of yum package:
~]# yumdb info yum
List out files contained in a Package
Similarly to rpm query, you can query from yum repository also, to do this, you need a program called repoquery. By using repoquery, you can query both individual packages and package group.
You can list all files contained by a package by using repoquery command, as shown below:
repoquery --list package_name
you need to replace package_name with specific package’s name, and list of containing files by that package will be on your screen.
For example, here we list all files contained by vim package:
repoquery --list vim
Yum has capabilities to install a single package, multiple packages or package group in one attempt, as per your choice.
Install Individual Packages
You can install a single package using the yum package manager by using the following command:
yum install package_name
you have the choice to install multiple packages by adding their name as argument in the above command, as shown below:
yum install package_name package_name…
Sometimes you need to install all similar packages into your system; you can use glob expression to do this activity.
For example, here we can install all packages of MySQL by using the following command:
~]# yum install mysql-* Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Setting up Install Process Package mysql-libs-5.1.73-8.el6_8.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package mysql.x86_64 0:5.1.73-8.el6_8 set to be updated ---> Package mysql-bench.x86_64 0:5.1.73-8.el6_8 set to be updated --> Processing Dependency: perl(DBI) for package: mysql-bench-5.1.73-8.el6_8.x86_64 ---> Package mysql-connector-java.noarch 1:5.1.17-6.el6 set to be updated ..... ..... Dependencies Resolved ===================================================================================== Package Arch Version Repository Size ===================================================================================== Installing: mysql x86_64 5.1.73-8.el6_8 base 895 k mysql-bench x86_64 5.1.73-8.el6_8 base 429 k mysql-connector-java noarch 1:5.1.17-6.el6 base 1.4 M mysql-connector-odbc x86_64 5.1.5r1144-7.el6 base 114 k mysql-devel x86_64 5.1.73-8.el6_8 base 130 k mysql-embedded x86_64 5.1.73-8.el6_8 base 2.4 M mysql-embedded-devel x86_64 5.1.73-8.el6_8 base 4.9 M ... ... Transaction Summary ===================================================================================== Install 83 Package(s) Upgrade 8 Package(s) Total download size: 68 M Is this ok [y/N]:
Like package name and glob expression, you can also pass the file name to yum install command. When you know the binary file name to install, but you don’t know the package name then you can pass the binary path to yum install command, as shown below:
~]# yum install /usr/sbin/named Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package bind.x86_64 32:9.8.2-0.68.rc1.el6_10.3 set to be updated --> Processing Dependency: bind-libs = 32:9.8.2-0.68.rc1.el6_10.3 for package: 32:bind-9 .8.2-0.68.rc1.el6_10.3.x86_64 --> Running transaction check --> Processing Dependency: bind-libs = 32:9.8.2-0.68.rc1.el6_10.1 for package: 32:bind-u tils-9.8.2-0.68.rc1.el6_10.1.x86_64 ---> Package bind-libs.x86_64 32:9.8.2-0.68.rc1.el6_10.3 set to be updated --> Running transaction check ---> Package bind-utils.x86_64 32:9.8.2-0.68.rc1.el6_10.3 set to be updated --> Finished Dependency Resolution Dependencies Resolved ===================================================================================== Package Arch Version Repository Size ===================================================================================== Updating: bind x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates 4.0 M Updating for dependencies: bind-libs x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates 892 k bind-utils x86_64 32:9.8.2-0.68.rc1.el6_10.3 updates 189 k Transaction Summary ===================================================================================== Install 0 Package(s) Upgrade 3 Package(s) Total download size: 5.1 M Is this ok [y/N]:
As you can see in the above command, we pass the binary path /usr/sbin/named to yum install command. In this case yum will search it through its package lists, and find the package which provides /usr/sbin/named and then install it on the system.
Sometimes you know the binary name of the package but don’t know in which bin or sbin directory is the file install; you can use the yum provides command as shown below:
~]# yum provides "*bin/named" Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca 32:bind-9.8.2-0.68.rc1.el6.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server Repo : base Matched from: Filename : /usr/sbin/named 32:bind-9.8.2-0.68.rc1.el6_10.3.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server Repo : updates Matched from: Filename : /usr/sbin/named 32:bind-9.8.2-0.68.rc1.el6_10.1.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server Repo : updates Matched from: Filename : /usr/sbin/named 32:bind-9.8.2-0.68.rc1.el6_10.1.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System) server Repo : installed Matched from: Filename : /usr/sbin/named
Installing a Package Group
A Package group is like a package only, but it is use to install all packages that serve a common purpose. It has a name and a groupid, you can use yum grouplist –v command to lists the names of all package groups and the groupid will display in the last pair of parentheses.
For example, here we check the group list for KDE desktop:
~]# yum -v grouplist kde* Loading "fastestmirror" plugin Loading "presto" plugin Config time: 0.026 Yum Version: 3.2.27 Setting up Group Process Loading mirror speeds from cached hostfile * base: centos.mirror.netelligent.ca * extras: centos.mirror.netelligent.ca * updates: centos.mirror.netelligent.ca rpmdb time: 0.001 group time: 0.160 Available Groups: KDE Desktop (kde-desktop) Done
To install a package group into the system, you can use group_name or groupid with yum groupinstall command as shown below:
yum groupinstall group_name yum groupinstall groupid
you can also use the yum install command to install package group by using @ symbol and groupid, as shown below:
yum install @group
The @ symbol tells yum that you need to perform groupinstall operation.
For example, we can use any one command from following to install KDE desktop:
~]# yum groupinstall "KDE Desktop" ~]# yum groupinstall kde-desktop ~]# yum install @kde-desktop
Similarly, to package installation, yum has capabilities to uninstall package both individual packages or package group.
Uninstall Individual Packages
You can remove any package by using yum remove command with the package name, as shown below:
yum remove package_name…
Like multiple package installation by yum, you can also remove multiple packages by adding the package name in the above command, as shown below:
~]# yum remove totem rhythmbox sound-juicer
Similarly, yum install you can use package name, glob expression, file lists, and the package provides with yum remove command.
Uninstall a Package Group
You can remove the package group by using yum is similar like yum group install syntax:
yum groupremove group yum remove @group
So, for example, you can remove KDE desktop package group by using any one command from following:
~]# yum groupremove "KDE Desktop" ~]# yum groupremove kde-desktop ~]# yum remove @kde-desktop
YUM Package Manager – Working with Transaction History
You can review the information about a timeline of yum transactions, date and time they occurred, affected packages, and most important transactions succeeded or not by using yum history command.
You can also undo or redo some of the transaction by using yum history command.
To list out of twenty recent transactions, you can run the command yum history without arguments or use below command:
~]# yum history list
To display all transaction, use the above command with all option, as shown below:
~]# yum history list all
If you want to display transactions within the given range, you can use the command, as shown below:
yum history list start_id..end_id
you have the choice to display transaction only related to a specific package; you can use the following command:
yum history list package_name yum history list glob_expression…
For example, display the first five transactions, type:
~]# yum history list 1..5 Loaded plugins: fastestmirror, presto ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 5 | root <root> | 2019-03-28 19:55 | Install | 1 < 4 | root <root> | 2019-03-28 19:53 | I, U | 11 > 3 | root <root> | 2019-03-28 19:52 | Install | 2 2 | root <root> | 2019-03-28 18:58 | Install | 10 1 | System <unset> | 2019-03-28 14:56 | Install | 206 history list
You will always get the output of yum history list command in tabular form, where each row consisting below mentioned columns:
• ID – it is an integer value use to identify the transaction.
• Login user – the name of the user, who has initiated the transaction. This information will display in Full Name <username> form. Some of the transaction which has initiated by the system itself, such as automatic system update will show System <unset> value in this column.
• Date and time – it will show the date and time when the transaction was issued.
• Action(s) – It will show a list of actions that were performed during a transaction, described in below table.
• Altered – It will show numbers of packages that were affected by a transaction with additional information.
Possible values of the Action:
|Downgrade||D||At least one package has been downgraded to an older version.|
|Erase||E||At least one package has been removed|
|Install||I||At least one new package has been installed.|
|Obsoleting||O||At least one new package has been marked as obsolete.|
|Reinstall||R||At least one package has been reinstalled.|
|Update||U||At least one package has been updated to a newer version|
Possible value of the Altered field
|<||Before the transaction finished, the rpmdb database was changed outside Yum.|
|>||After the transaction finished, the rpmdb database was changed outside Yum.|
|*||The transaction failed to finish.|
|#||The transaction finished successfully, but yum returned a non-zero exit code.|
|E||The transaction finished successfully, but an error or a warning was displayed.|
|P||The transaction finished successfully, but problems already existed in the rpmdb database.|
|S||The transaction finished successfully, but the –skip-broken command-line option was used and certain packages were skipped.|
You can also display a summary of all transactions, by using the following command:
yum history summary
you can display a summary of the transaction for given range by using below command:
yum history summary start_id..end_id
You can also view the transaction summary for a specific package, as shown below:
yum history summary glob_expression…
For example, here we printing transactions history summary for the first 5 transactions:
~]# yum history summary 1..5 Loaded plugins: fastestmirror, presto Login user | Time | Action(s) | Altered ------------------------------------------------------------------------------- System <unset> | Last 6 months | Install | 206 root <root> | Last 6 months | I, U | 24 history summary
The command yum history list and yum history summary are used for transactions, and it will display transactions related information of packages, not giving the information about packages such as package versions, etc.
To list the transactions information along with packages details, you can use the following form of the command:
yum history package-list glob_expression…
For example, you can get the history and packages information of subscription-manager by using the following command:
~]# yum history package-list subscription-manager*
You can display a single transaction’s summary by using the following form of the command:
yum history summary id
You can use yum history info command to get the detailed information of a particular transaction, as shown below:
yum history info id…
The id option in the above command, when you missed it will show you last transaction details.
If you want to specify more than one transaction, you can use the range of transaction id.
yum history info start_id..end_id
For example, here we check the information of transactions 4 and 5, by using the following command:
~]# yum history info 4..5 Loaded plugins: fastestmirror, presto Transaction ID : 5 Begin time : Thu Mar 28 19:55:44 2019 Begin rpmdb : 229:255176564858a97bd5ad23343ad9f1df106123f3 ** End time : 19:55:46 2019 (2 seconds) End rpmdb : 230:0379d3eca4d368b699a7cafb05dac6c52770ac04 User : root <root> Return-Code : Success Transaction performed with: Installed rpm-4.8.0-12.el6.x86_64 Installed yum-3.2.27-14.el6.centos.noarch Installed yum-plugin-fastestmirror-1.1.26-11.el6.noarch Installed yum-presto-0.6.2-1.el6.noarch Packages Altered: Install gdb-7.2-92.el6.x86_64 ------------------------------------------------------------------------------- Transaction ID : 4 Begin time : Thu Mar 28 19:53:05 2019 Begin rpmdb : 218:d18972c90ac5531fa1179a980d833296b71d1c19 End time : 19:53:08 2019 (3 seconds) End rpmdb : 228:8968163df21d2f720616f4e515c14f3c260839c4 ** User : root <root> Return-Code : Success Transaction performed with: Installed rpm-4.8.0-12.el6.x86_64 Installed yum-3.2.27-14.el6.centos.noarch Installed yum-plugin-fastestmirror-1.1.26-11.el6.noarch Installed yum-presto-0.6.2-1.el6.noarch Packages Altered: Dep-Install apr-1.3.9-5.el6_9.1.x86_64 Dep-Install apr-util-1.3.9-3.el6_0.1.x86_64 Dep-Install apr-util-ldap-1.3.9-3.el6_0.1.x86_64 Dep-Install httpd-2.2.15-69.el6.centos.x86_64 Dep-Install httpd-tools-2.2.15-69.el6.centos.x86_64 Dep-Install mailcap-2.1.31-2.el6.noarch Dep-Install make-1:3.81-23.el6.x86_64 Updated openssl-1.0.0-4.el6.x86_64 Update 1.0.1e-57.el6.x86_64 Install php-5.3.3-49.el6.x86_64 Dep-Install php-cli-5.3.3-49.el6.x86_64 Dep-Install php-common-5.3.3-49.el6.x86_64 history info
You can also check the additional information of transaction like configuration options used at time of the transaction, from which repository and why were packages installed, etc. To get this additional information you can use “yum history” command in the following form:
yum history addon-info id
In the above command also if you missed id, it will display information of the latest transaction, and another way to check the latest transaction is to use last option with the command, as shown below:
yum history addon-info last
For example, here we check transaction information with additional details for numbered 4 transactions.
~]# yum history addon-info 4
There is three additional information in this type of transaction:
• Config-main – it represents tum’s global options used during the transaction.
• Config-repos – it shows used options for the individual yum repository.
• Saved_tx – it is the data that can be used by the yum load-transaction command to repeat the transaction on another machine.
You can use the following command to display the selected type of additional information:
yum history addon-info id information
Reverting and Repeating Transactions
Apart from reviewing the transaction history, yum has capabilities to revert or repeat the selected transaction.
You can revert transaction by using the following form of yum history command:
yum history undo id
And, you can use below form of the command to repeat transaction:
yum history redo id
you can use last option with both commands to apply the operation with the latest transaction.
These yum command can only repeat or revert the steps which followed during the transaction. If the transaction installed a new package, the yum history undo will uninstall it and if the transaction were uninstalled a package, it would again install it.
We are also using these command to update and downgrade packages to their previous version of these older packages are still available.
If you are managing several identical systems, you can use yum to perform a transaction on one system and store the transaction details in a file and after testing repeat the same transaction on other remaining systems to perform same tasks.
You can store the transaction details into a file by using the following command:
yum -q history addon-info id saved_tx > file_name
after copy this file into another system, you can repeat the transaction by using the following command:
yum load-transaction file_name
Note: the rpmdb version stored in the file must be identical to the version of the target system. You can verify the rpmdb version by using yum version nogroups command.
Sometimes due to power failure or system crash and other problems transaction not get completed. When such an event happened with you, you can resume the transactions by using the following command:
The yum-complete-transaction will search incomplete and aborted transactions on the system and try to complete them.
The transactions information saved into the /var/lib/yum/transaction-all and /var/lib/yum/transaction-done file. If there is an incomplete transaction, Yum-complete-transaction will attempt to complete from the most recent one.
You can clean transaction journal files without attempting to resume the incomplete transactions, use the –clean-only option, as shown below:
Starting New Transaction History
Yum package manager stores all transaction history in single SQLite database file. If you want to start new transaction history, you can do it by run below command:
yum history new
The above command will create a new empty database file at /var/lib/yum/history/ directory. The old database file will be kept, but not be accessible until the newer database file is present in the directory.
Configuring Yum Package Manager and Yum Repository
You can find the Yum configuration file at /etc/yum.conf.
This configuration file has two important sections, one is mandatory [main] section and can also one more [repository] section configured.
The [main] section contains yum option which applied with global effect and the [repository] section allow to configure repository-specific options.
We always recommended configuring the individual repository in a new file with extension .repo at /etc/yum.repos.d/ directory.
The value you configure in individual [repository] section of the file /etc/yum.conf overrides values set in the [main] section.
Here some tips for configuring yum:
- You should set global yum option by editing [main] section of the /etc/yum.conf configuration file.
- Configure individual repository option by editing [repository] sections in /etc/yum.conf and .repo files in the /etc/yum.repos.d/ directory;
- Configure global yum variables in /etc/yum.conf file and repository files in the /etc/yum.repos.d/ Directory, it will help you to handle dynamic version and architecture values.
- Always use the command line to add, enable, and disable Yum repositories.
- Setup your own custom Yum repository.
Setting [main] Options
The Yum configuration file /etc/yum.conf contains [main] section and key-value of this section affect how yum operates and how it treats repositories.
The /etc/yum.conf configuration file’s contents look like this:
[main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=3 [comments abridged] # PUT YOUR REPOS HERE OR IN separate files named file.repo # in /etc/yum.repos.d
Here you can find the most used options in [main] section:
|0||yum should prompt for confirmation of critical actions it performs. This is the default.|
|1||Do not prompt for confirmation of critical yum actions. If assumeyes=1 is set, yum behaves in the same way that the command-line option -y does.|
The directory is an absolute path of the directory where yum should store its cache and database files.
By default, yum’s cache directory is /var/cahe/yum/$basearch/$releaserver.
The value is an integer between 0 and 10. Where debuglevel=0 will disable the debugging output, and higher value will cause yum to display more detailed debugging output. The default value is 2.
|0||Do not take into account the exact architecture when updating packages.|
|1||Consider the exact architecture when updating package. With this setting, yum will not install an i686 package to update an i386 package already installed on the system. This is the default.|
This option is use to exclude packages by keyword while installation or update. You can list multiple packages here by using a space-delimited list, and also can use wildcard characters, for example, * and ? are allowed.
|0||Disable GPG signature-checking on packages in all repositories, including local package installation.|
|1||Enable GPG signature-checking on all packages in all repositories, including local package installation. gpgcheck=1 is the default, and thus all packages signatures are checked.|
The GPG-checking rule can configure into individual repository section also.
|0||yum should not check the dependencies of each package when removing a package group. Using this setting, yum will remove all packages from package group whether those packages are required by other packages or groups. This is the default value.|
|1||By using this value, yum will check the dependencies of each package when removing package group, and remove only those packages which are not required by any other package or group.|
installonlypkgs=space separated list of packages
Here you can mention the package name with space separated which yum can install but will never update.
In this list we are including the package we don’t want to update automatically, like kernel.
Here the value is an integer represent the maximum number of versions that can installed simultaneously for any single package listed in the installonlypkgs directive.
|0||Do not retain the cache of headers and packages after a successful installation. This is the default.|
|1||Retain the cache after a successful installation.|
It is the absolute path of the log file for yum, where it is logging the output. The default location of the log file of yum is /var/log/yum.log.
There are two values for this option:
- best – it will install the best choice architecture for the system. For example, setting multilib_policy=best on an AMD64 system, yum will install 64-bit versions of all packages.
- all – it will install possible architecture for packages. For example, setting multilib_policy=all on AMD64 system, yum would install both the i686 and AMD64 version of a package, if both are available.
|0||Disable yum’s obsoletes processing logic when performing updates.|
|1||Enable yum’s obsoletes processing logic when performing updates. When one package declares in its spec file that it obsoletes another package, the latter package will be replaced by the former package when the former package is installed. Obsoletes are declared, for example, when a package is renamed. obsoletes=1 is the default.|
|0||Use to disable all yum plug-ins globally.|
|1||Use to enable all yum plug-ins globally.|
It is the absolute path of the directory where . repo files located. These . repo files are containing the information of repository, similar to [repository] section of /etc/yum.conf file.
The value is integer 0 or greater. It is use to set the number of times yum should try to retrieve a file before prompting error. You can set the value 0 to make yum retry forever; the default value is 10.
Setting [repository] Options
The [repository] section has unique repository ID such as my_personal_repo, where space is not allowed. It allows as to define individual Yum repositories, but to avoid conflicts don’t use the same name for repository used by Red Hat repositories.
Below is the example of [repository] section with minimum keys:
[repository] name=repository_name baseurl=repository_url
These are the basic directive need to configure with every [repository]
It is a human-readable string to describe the repository name.
The baseurl use to set repository_url, which is the path of the directory where repodata directory located. You can use various internet protocol to define the repodata:
- When repository is available over HTTP protocol, use: http://path/to/repository
- When repository is available over FTP protocol, use: ftp://path/to/repository
- When the repository is on the local machine, use: file://path/to/local/repository
The general format of http link for base URL is like:
Useful [repository] directive is following:
|0||Do not include this repository as a package source when performing updates and installs. This is the easiest way to on and off repositories, which is useful when you desire a single package from a repository that you do not want to enable for updates or installs.|
|1||Include this repository as a package source.|
You can see the sample example of repository file is like below:
Sample of /etc/yum.repos.d/redhat.repo file
# # Red Hat Repositories # Managed by (rhsm) subscription-manager # [red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-rpms] name = Red Hat Enterprise Linux Scalable File System (for RHEL 6 Entitlement) (RPMs) baseurl = https://cdn.redhat.com/content/dist/rhel/entitlement-6/releases/$releasever/$basearch/scalablefilesystem/os enabled = 1 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release sslverify = 1 sslcacert = /etc/rhsm/ca/redhat-uep.pem sslclientkey = /etc/pki/entitlement/key.pem sslclientcert = /etc/pki/entitlement/11300387955690106.pem [red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-source-rpms] name = Red Hat Enterprise Linux Scalable File System (for RHEL 6 Entitlement) (Source RPMs) baseurl = https://cdn.redhat.com/content/dist/rhel/entitlement-6/releases/$releasever/$basearch/scalablefilesystem/source/SRPMS enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release sslverify = 1 sslcacert = /etc/rhsm/ca/redhat-uep.pem sslclientkey = /etc/pki/entitlement/key.pem sslclientcert = /etc/pki/entitlement/11300387955690106.pem [red-hat-enterprise-linux-scalable-file-system-for-rhel-6-entitlement-debug-rpms] name = Red Hat Enterprise Linux Scalable File System (for RHEL 6 Entitlement) (Debug RPMs) baseurl = https://cdn.redhat.com/content/dist/rhel/entitlement-6/releases/$releasever/$basearch/scalablefilesystem/debug enabled = 0 gpgcheck = 1 gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release sslverify = 1 sslcacert = /etc/rhsm/ca/redhat-uep.pem sslclientkey = /etc/pki/entitlement/key.pem sslclientcert = /etc/pki/entitlement/11300387955690106.pem
Using Yum Variable
There are some variables known as Yum variable use in the yum command line and yum configuration files.
Some of the variables explained below:
This variable is use to reference the release version of Red Hat Linux. Yum gets the value of $rleasever from the distroverpkg=value line in the /etc/yum.conf configuration file.
The value of $releasever typically consists of the major release number and the variant of Red Hat Linux, for example, Client and Server.
This variable use to represent the CPU architecture as returned when calling Python function os.uname(). The valid values of $arch include i686 and x86_64.
The $basearch variable represents the base architecture of the system. For example, i686 machine has a base architecture of i386, and AMD64 and Intel 64 machines have a base architecture of x86_64.
These 10 variables replaced with the value of any shell environment variables with the same name. If one of these variables referenced and a shell environment variable with the same name does not exist, then the configuration file variable is not replaced.
You can also define the custom variable and override the value of the existing variables. To create a variable, first, create a file with the same name without $ sign in the /etc/yum/vars/ directory, and add the desired value on the first line of the file.
For example, to define a new variable called $osname, create a new file with the name of osname and add Red Hat Enterprise Linux on the first line of the file and save the file as /etc/yum/vars/osname:
~]# echo "Red Hat Enterprise Linux" > /etc/yum/vars/osname
Now instead of Red Hat Enterprise Linux, you can use the following in the .repo files:
Viewing Current Configuration
To display the current configuration of global yum option configured in [main] section of file /etc/yum.conf, use the following command:
You can also view the configuration of the specific section, by using below command form:
You can also use glob expression to view configuration from all matching sections:
For example, here we display all configuration options with their corresponding values, by using the following command:
~]# yum-config-manager main *
Adding, Enabling and Disabling Yum Repository
In this section, we will learn to add, enable, and disable a repository by using the yum-config-manager command.
Adding a Yum Repository
You can define a new repository by adding a [repository] section into /etc/yum.conf file or by creating a .repo file in the /etc/yum.repos.d/ directory.
Yum repository generally provides their own .repo file to add that repository on your system and enable it, by running the following command:
yum-config-manager --add-repo repository_url
here repository_url is the link of .repo file.
For example, to add a repository located at https://linuxconcept.com/linux.repo, type the following at a shell prompt:
~]# yum-config-manager --add-repo https://linuxconcept.com/linux.repo
Enabling a Yum Repository
You can enable repository or repositories by using the following command:
yum-config-manager --enable repository…
You can also use the glob expression to enable all matching repositories:
yum-config-manager --enable glob_expression…
For example, to enable repositories defined in the [linuxconcept], [linuxconcept-source] and [linuxconcept-example] section, use below command:
~]# yum-config-manager --enable linuxconcept*
When the repository get enabled successfully, the above command will display the current repository configuration.
Disabling a Yum Repository
You can disable yum repository by using the following command:
yum-config-manager --disable repository…
You can also use glob expression to disable all matching repositories:
yum-config-manager --disable glob_expression…
when the above command runs successful, it displays the current configuration.
Creatinga Yum Repository
In this section, we will learn to create a yum repository.
You can set up a Yum repository by the following steps:
Step 1 – Install the createrepo package
You can install “createrepo” package by using the following command:
yum install createrepo
Step 2 – Create a repo directory
Create one directory for the new repository. Generally, we are creating a custom repository directory in /mnt or /media directory and copy all files into that directory or mount the ISO file in the directory.
Step 3 – Create repository
We can create a repository by using new repo directory, as shown below:
createrepo --database /media/local_repo
The above command will create necessary metadata for your yum repository.
Working with Yum Cache
By default, yum deletes all downloaded files which are not needed after a successful operation. It helps to manage minimum storage space for yum uses.
You can enable cache, which can enable the functionalities to store the data files in the cache directory which will help you to do an operation in offline mode also.
Yum, store all temporary file in the /var/cache/yum/$basearch/$releasever/ directory, where $basearch is represent the base architecture of CPU, and $releasever represent the release version.
You can change the cache directory location by editing yum configuration file /etc/yum.conf.
Enabling the cache
To enable cache of packages after successful installation, need to configure by adding below the line in [main] section of /etc/yum.conf file.
keepcache = 1
After enabling the cache, the yum operation may download package data from the configured repositories.
You can use below command to download and make usable all the metadata for currently enabled yum repositories:
This command is useful to make sure cache data is fully up to date with all metadata. You can configure metadata expire time by configuring metadata-expire parameter in /etc/yum.conf file settings.
Using yum in Cache-only Mode
To use yum utility in cache only mode use the -c option with yum command. It will work without a network connection and getting data from the cache. You can also use the option –cacheonly as an alternative.
By using cache only option the yum will install only packages which are already downloaded and available in cache data.
You can list the packages that are currently using cached data with name, by using the following command:
yum -C list gstreamer*
Clear yum Caches
Clear yum cache processes to clean the directory /var/cache/yum, but it will not affect on installed packages.
You can remove currently enabled repositories from the cache, by using the following command:
yum clean all
There are multiple option you can use with yum clean command:
|expire-cache||Use to revalidate cache for all repositories the next time it is used.|
|packages||Eleminates any cached packages from the system.|
|headers||It use to eliminates all header file that previous versions of yum used for dependency resolution|
|metadata||It eliminates the metadata of yum cached. These metadata will download again at the next yum run.|
|dbcache||It is use to eliminates the sqlite cache used for faster access to metadata.|
|rpmdb||It is for eliminates all cached data from the local rpmdb.|
|plugins||Use to enable plugins are forced to eliminate their cached data.|
|all||Remove all types of cached data.|
Yum has multiple plug-ins capabilities that extend and enhance yum operations. Some of the plug-ins installed by default.
You can get the information about installing yum plug-ins by using the following command:
~]# yum info yum
Enabling, Configuring, and Disabling Yum Plug-ins
To enable plug-ins to need to configure plugins=1 into [main] section of /etc/yum.conf file.
To disable all plug-ins, you can change the value of plugins=1 to plugins=0.
The plug-ins are also having its own configuration file in the /etc/yum/pluginconf.d/ directory. These files are used to configure options for specific plug-ins.
These plug-ins configuration files always contain [main] section.
One you disabled all plugins by setting option plugins=0 at /etc/yum.conf, all plugins will get disabled which are not configured for enable in the individual configuration file, it means individual files configuration will always override to yum.conf settings.
You can also disable one or multiple plugins by using the single yum command, use the following command:
~]# yum update --disableplugin=presto ~]# yum update --disableplugin=presto,refresh-pack*
Install Additional Yum Plug-ins
To install new yum plug-ins into the system, you can use below command:
~]# yum install yum-plugin-security
Here you can replace yum-plugin-security with your plugin name.
In this section, we will learn about the essential and useful yum plug-ins.
The plug-in search-disabled-repos help to temporarily and permanently enable and disable to resolve dependencies.
This plug-in helps to work with repositories that are managed by subscription-manager not with custom repositories.
To configure “search-disabled-repos” plug-in need to configure file located in /etc/yum/pluginconf.d/search-disabled-repos.conf.
The “[main]” section of this plug-in supports these directives:
|enabled=value||It is use to enable or disable the plug-in. the value either 1 (enable) or 0 (disable). The plug-in is enabled by default.|
|notify_only=value||It is use to configure behaviour of the plug-in to notification. The value of this directive must be either 1 (notify only without modifying the behaviour of yum), or 0 (modify the behaviour of yum). By default the plug-in only notifies the user.|
|ignored_repos=repositories||It specify the repositories that will not be enabled by the plug-in.|
The kabi plug-in is use to checks driver update package conforms with Red Hat kernel application Binary Interface (kabi). When this plugin is enabled, and you try to install any package that uses kernel symbols which are not whitelisted, a warning message written to the system log.
You can configure kabi plug-in by an editing configuration file located in /etc/yum/pluginconf.d/kabi.conf.
|enabled=value||It is use to enable and disable plug-in just like another plug-in.|
|whitelists=directory||It is use to configure directory path which has files with supported kernel symbols. By defult, the kabi plug-in uses files provided by the kernel-abi-whitelists package (that is, the /lib/modules/kabi/ directory).|
|enforce=value||It is use to enable and disable it in enforcing mode. It support value 1 for enable and 0 for disable.|
The presto plug-in support to yum to download delta RPM packages while updating, from repositories which have presto metadata enabled. Delta RPMs contain the information about package differences between the version of the package installed on a client machine and the updated version in the repository.
This plug-in use to manage product identity certificates for products installed from the Content Delivery Network. This is by default, installed in the system.
The refresh-packagekit plug-in use to update metadata for PackageKit whenever yum command running. It is by default installed on the system.
The rhnplugin is use for connecting RHN Classic, it allows to update and install packages for the system that registered with RHN Classic.
Yum has a security plug-in to extend yum with a set of useful security-related commands, subcommands, and options.
You can check the security-related update on the terminal, as shown below:
~]# yum check-update --security
To update security affected packages by using either yum update –security or yum update-minimal –security options.
The subscription-manager plug-in use to connect the system with Red Hat Network, it is for connecting the Red Hat Network to update and install packages from the certificate-based Content Delivery network. It is installed in the system by default.
This plug-in (yum-downloadonly) provides an option –downloadonly in yum command-line option which is use to download packages from Red Hat Network and configure yum repository without installing the packages.
The configuration file of this plug-in is located in /etc/yum/pluginconf.d/downloadonly.conf.
~]# cat /etc/yum/pluginconf.d/downloadonly.conf
For example, here we use –downloadonly option to download the latest version of the httpd package, without installing it:
~]# yum install httpd --downloadonly
By default, packages are download using –downloadonly option are stored in one of the subdirectories of the /var/cache/yum directory, which is depending on Red Hat Linux variant and architecture.
If you want to store the downloaded file into a different location, use the –downloaddir option, as shown below:
~]# yum install --downloadonly --downloaddir=/path/to/directory httpd
To get more information on Yum package manager to work with Red Hat-based Linux system, you can refer to these resources.
- yum – The manual page of the yum command-line utility gives you a complete list of options supported by the yum command.
- yumdb – the manual page of yumdb command-line utility provides information to use this tool to query and if need, alter yum database.
- yum.conf – The manual page of yum.conf is document available with supported options to configure yum using yum.conf file.
- yum-utils – the manual page of yum-utils is list and describe the information on additional utilities to manage and configure yum.