How to Install Specific Version of Package using YUM

Sometimes, you may need to have a certain version of a package installed on your system to conform to a certain requirement. In this article, we are going to see how we can install specific versions of packages using yum package manager in Centos  & RHEL 7/8. First, we need to know the available versions for a particular package.

Read Also: How to Install Specific Version of Package using apt-get

Check available versions

Open the terminal run the following command to see all available versions of a package:

yum --showduplicates list

In this example, we are going to list the available versions of samba in your enabled repositories for RHEL 7 system.

 yum --showduplicates list samba

Sample Output

Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Available Packages
samba.x86_64              4.1.1-31.el7                   rhui-REGION-rhel-server-releases
samba.x86_64              4.1.1-33.el7_0                 rhui-REGION-rhel-server-releases
samba.x86_64              4.1.1-35.el7_0                 rhui-REGION-rhel-server-releases
samba.x86_64              4.1.1-37.el7_0                 rhui-REGION-rhel-server-releases
samba.x86_64              4.1.1-38.el7_0                 rhui-REGION-rhel-server-releases
samba.x86_64              4.1.12-21.el7_1                rhui-REGION-rhel-server-releases
samba.x86_64              4.1.12-23.el7_1                rhui-REGION-rhel-server-releases
samba.x86_64              4.1.12-24.el7_1                rhui-REGION-rhel-server-releases
samba.x86_64              4.2.3-10.el7                   rhui-REGION-rhel-server-releases
samba.x86_64              4.2.3-11.el7_2                 rhui-REGION-rhel-server-releases
samba.x86_64              4.2.3-12.el7_2                 rhui-REGION-rhel-server-releases
samba.x86_64              4.2.10-6.el7_2                 rhui-REGION-rhel-server-releases
samba.x86_64              4.2.10-6.2.el7_2               rhui-REGION-rhel-server-releases
samba.x86_64              4.2.10-7.el7_2                 rhui-REGION-rhel-server-releases
samba.x86_64              4.4.4-9.el7                    rhui-REGION-rhel-server-releases
samba.x86_64              4.4.4-12.el7_3                 rhui-REGION-rhel-server-releases
samba.x86_64              4.4.4-13.el7_3                 rhui-REGION-rhel-server-releases
samba.x86_64              4.4.4-14.el7_3                 rhui-REGION-rhel-server-releases
samba.x86_64              4.6.2-8.el7                    rhui-REGION-rhel-server-releases
samba.x86_64              4.6.2-10.el7_4                 rhui-REGION-rhel-server-releases
samba.x86_64              4.6.2-11.el7_4                 rhui-REGION-rhel-server-releases
samba.x86_64              4.6.2-12.el7_4                 rhui-REGION-rhel-server-releases

Since Yum uses the RPM package manager for handling packages, the package names are based on the RPM package label format.

In the above example, the first column indicates the package name & it's architecture and the second column shows the version of the package. As you'll also notice, the latest package is the one located at the bottom of the list.
In this case, samba-4.6.2-12 is the latest package.

Install a Specific version of a package

Now we can proceed and install any version of the samba package. To do this, run we are going to append the version of the package at the end. i.e

yum install <packagename> <version>

To install the latest version which is 4.6.2-12 according to our output as displayed earlier, run the command below

yum install samba-4.6.2-12

If you want to be more specific, you can include the version release as shown

yum install samba-4.6.2-12.el7_4

Sample Output

--> Finished Dependency Resolution

Dependencies Resolved

 Package                                 Arch                        Version                                Repository                                             Size
 samba                                   x86_64                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      633 k
Installing for dependencies:
 avahi-libs                              x86_64                      0.6.31-17.el7                          rhui-REGION-rhel-server-releases                       61 k
 cups-libs                               x86_64                      1:1.6.3-29.el7                         rhui-REGION-rhel-server-releases                      356 k
 libldb                                  x86_64                      1.1.29-1.el7                           rhui-REGION-rhel-server-releases                      128 k
 libtalloc                               x86_64                      2.1.9-1.el7                            rhui-REGION-rhel-server-releases                       33 k
 libtdb                                  x86_64                      1.3.12-2.el7                           rhui-REGION-rhel-server-releases                       47 k
 libtevent                               x86_64                      0.9.31-1.el7                           rhui-REGION-rhel-server-releases                       36 k
 libwbclient                             x86_64                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      105 k
 pytalloc                                x86_64                      2.1.9-1.el7                            rhui-REGION-rhel-server-releases                       16 k
 samba-client-libs                       x86_64                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      4.7 M
 samba-common                            noarch                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      198 k
 samba-common-libs                       x86_64                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      164 k
 samba-common-tools                      x86_64                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      456 k
 samba-libs                              x86_64                      4.6.2-12.el7_4                         rhui-REGION-rhel-server-releases                      265 k

Transaction Summary
Install  1 Package (+13 Dependent packages)

Total download size: 7.2 M
Installed size: 24 M
Is this ok [y/d/N]:

Installation complete

  samba.x86_64 0:4.6.2-12.el7_4

Dependency Installed:
  avahi-libs.x86_64 0:0.6.31-17.el7         cups-libs.x86_64 1:1.6.3-29.el7      libldb.x86_64 0:1.1.29-1.el7              libtalloc.x86_64 0:2.1.9-1.el7
  libtdb.x86_64 0:1.3.12-2.el7              libtevent.x86_64 0:0.9.31-1.el7      libwbclient.x86_64 0:4.6.2-12.el7_4       pytalloc.x86_64 0:2.1.9-1.el7
  samba-client-libs.x86_64 0:4.6.2-12.el7_4 samba-common.noarch 0:4.6.2-12.el7_4 samba-common-libs.x86_64 0:4.6.2-12.el7_4 samba-common-tools.x86_64 0:4.6.2-12.el7_4
  samba-libs.x86_64 0:4.6.2-12.el7_4


Note: Exclude package in the repo file otherwise for the next yum update it will install the latest version

To verify its installation, type:

rpm -qa | grep samba

We hope this article has been insightful to you and you'll be more comfortable in installing specific versions of packages using Yum in your system.  Feel free to get in touch and ask any questions. Thank you for your time.

Leave a Comment