How to Install Particular Package Version in CentOS and Ubuntu

Usually, when you install a package in CentOS and Ubuntu, the package management software selects the latest package version from the repository, by default. However, sometimes, for one reason or the other, you may want to install a specific package version on your Linux system.

In this article, we will explain how to install a particular or specific package version in CentOS and Ubuntu using Yum and APT front-end package managers, respectively.

Install Specific Package Version in CentOS/RHEL/Fedora

First, you need to check for all the available versions of a package, whether installed or not. Normally, yum ignores specific versions of a package and will always try to install the latest version available.

Secondly, when you try to find info about a package, yum only shows the latest version of that package in the output of info, list or search sub-commands; but using the --showduplicates switch, you can display all package versions present in the repository.

# yum --showduplicates list nginx
List All Package Versions in CentOS
List All Package Versions in CentOS

From the above command output, the naming format for packages are:

package_name.architecture  version_number–build_number  repository

The build_number represents minor changes made by the package maintainer, not by the program author, such as additional documentation, changes to configuration files, or bug fixes and more.

Once you have identified the specific version of a package (for example nginx-1.10.3-1.el7.ngx), install it as follows. Note that the name format will have to change here, to the full RPM desired, package_name-version_number as shown in the following command.

# yum install nginx-1.10.3

Alternatively, if you want to use a version with certain updates, specify the build_number (package_name-version_number-build_number) as shown.

# yum install nginx-1.10.3-1.el7.ngx
Install Particular Package Version in CentOS
Install Particular Package Version in CentOS

Considering the above situation, a newer version of the packages is already installed on the system. Therefore, you need to remove the installed package version, if you want to install an older version from the available packages as shown.

# yum remove nginx

Once you have removed the installed package, you can then install the specific version you desire as explained above.

Install Specific Package Version in Ubuntu and Debian

First check the version of the package installed on your system plus all available packages in the repository, using the apt-cache command below.

$ apt-cache policy firefox
Check Installed Package Version in Ubuntu
Check Installed Package Version in Ubuntu

To install a specific package version, use the following command with syntax below.

$ sudo apt install firefox=45.0.2+build1-0ubuntu1
Install Specific Package Version in Ubuntu
Install Specific Package Version in Ubuntu

If a newer version of a package is already installed on your Ubuntu system, you can remove it and then install the version you want.

$ sudo apt remove firefox
$ sudo apt install firefox=45.0.2+build1-0ubuntu1

That’s all! For more information, refer to the yum, apt, apt-cache man pages. If you have any queries, use the comment form below to get to us.

Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

4 thoughts on “How to Install Particular Package Version in CentOS and Ubuntu”

  1. Hi, could you assist with installing a specific version of Nginx on Ubuntu?

    I am getting the below after following this.

    root@web-server-nginx:~# apt-get install nginx=1.14.0-0ubuntu1
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    
    The following packages have unmet dependencies:
     nginx : Depends: nginx-core (< 1.14.0-0ubuntu1.1~) but 1.14.0-0ubuntu1.7 is to be installed or
                      nginx-full (< 1.14.0-0ubuntu1.1~) but it is not going to be installed or
                      nginx-light (< 1.14.0-0ubuntu1.1~) but it is not going to be installed or
                      nginx-extras (< 1.14.0-0ubuntu1.1~) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    
    Reply
    • @Eugene,

      Which Ubuntu release version you are using? try to update or upgrade and then try to install the specific Nginx version…

      Reply
  2. Thanks for this article! Can I upgrade installed Samba version on CentOS 6.9 to latest available samba version e.g. I have samba-3.6.23 on CentOS 6.9 and I would like to update it to samba-4.6.2, as the CentOS 6.9 repo does not offer this latest version of samba, can I add a repo to CentOS 6.9 which offers latest version of samba and then upgrade it using yum? If I upgrade like this, will it affect all future yum system updates?

    I would like to upgrade my SMB protocol from version 2.0.2 to SMB version 3.1.1, we have all latest Windows 10 clients and Samba FileServer (CentOS 6.9). Can you suggest a possible solution? Thank you!

    Reply
    • @Rahul

      You may have to build samba and the SMB protocol from source, in order to install the exact versions you want on CentOS 6.9.

      Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.