How to use yum to install a specific version of a Package?

Updated on September 2, 2017

If you ever want to instruct YUM to install only a particular version of a package, then here’s how you can do that. Well, there can be a multiple versions of package in the yum repository and if not instructed, yum will install the default version. But sometimes you might want to install only a particular version of a package and yum allows you to choose what to install. The first thing you should do is, to find out all the available versions of a package using –showduplicates switch. This particular switch will search for the given package and lists the available version (including the base and updated versions).

# yum --showduplicates list vsftpd
 Available Packages
 vsftpd.x86_64                                                                                                     3.0.2-10.el7                                                                                                        base
 vsftpd.x86_64                                                                                                     3.0.2-11.el7_2                                                                                                    updates

Moreover, the above command will also list the version of a package that was already installed in the system under ‘Installed Packages’. For example, the below command lists duplicates for openssh package and also the version of the installed package as well.

# yum --showduplicates list openssh | expand
 Installed Packages
 openssh.x86_64                    6.6.1p1-25.el7_2                     installed
 Available Packages
 openssh.x86_64                    6.6.1p1-22.el7                          base
 openssh.x86_64                    6.6.1p1-23.el7_2                     updates
 openssh.x86_64                    6.6.1p1-25.el7_2                     updates

yumdownloader package

How to install a specific version of a package?

You need to append the version information of the package as shown below:

# yum install vsftpd-3.0.2-11.el7_2
 ::::::::::::::::::::::::
 Resolving Dependencies
 --> Running transaction check
 ---> Package vsftpd.x86_64 0:3.0.2-11.el7_2 will be installed
 :::::::::::::::::::::

It’s absolutely fine to append architecture and release information as well.

# yum install vsftpd-3.0.2-11.el7_2.x86_64

Not sure how to construct/append the version, release and architecture information of a package? You can take help from repoquery command. The command repoquery is part of yum-utils package, so if you don’t find one, install it as shown below:

# yum install yum-utils
$ repoquery --show-duplicates vsftpd*
vsftpd-0:3.0.2-10.el7.x86_64
vsftpd-0:3.0.2-11.el7_2.x86_64

You can also download the RPM of a package with a specific version using yumdownloader command.

$ yumdownloader vsftpd-0:3.0.2-10.el7.x86_64
vsftpd-3.0.2-10.el7.x86_64.rpm                             | 167 kB   00:02
$ ls -lrt
-rw-rw-r--. 1 centos centos 170800 Nov 25  2015 vsftpd-3.0.2-10.el7.x86_64.rpm

You can use –resolve switch with yumdownloader to check for the dependencies.

$ yumdownloader --resolve <package_name>

Install the downloaded RPM file locally as shown below:

# yum localinstall vsftpd-3.0.2-10.el7.x86_64.rpm

Was this article helpful?

Related Articles

Leave a Comment