
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Install Particular Package Version in CentOS and Ubuntu
As Linux users, we often find ourselves needing to work with different versions of packages on your system. Sometimes, we need to use a specific feature that is only available in a newer version of the package, or there could be compatibility issues with other software on my system that only work with a particular version of the package. This is where the ability to install a particular package version comes in handy.
In this article, we will go through various methods to install a particular version of a package in CentOS and Ubuntu. We'll explore the use of package managers, RPM or DEB package files, and compiling from source code. It's important to note that the commands used in this article assume that you have root or sudo privileges on your system. Let's begin with the article and make sure to read it till the end to understand it properly.
Method 1: Using Yum or Apt-Get Package Manager
Sometimes as Linux users, we need to install a specific version of a package on the system, maybe because we want to use a new feature or because a newer version of the package has unsuitable problems with other software on the system. The easiest way to do this is by using the built-in package manager, which is Yum (Yellowdog Updater Modified) for CentOS and Apt-Get for Ubuntu. These package managers allow you to install a specific version of a package that you want.
Step 1 ? List All Available Versions
Before installing a specific version of a package using the Yum method or command, you must check for all available versions of the package that are currently available on your machine. To do this, you can use the following command in the terminal or prompt ?
yum --showduplicates list [package-name]
Suppose, if you want to install version 1.2.3 of the Apache web server, you would run ?
yum --showduplicates list httpd
The command above will display a list of all the available versions of the specified package, including their corresponding repository sources and installation status. As an example, see the following output below ?
httpd.x86_64 2.2.15-69.el6.centos.2 updates httpd.x86_64 2.2.15-69.el6.centos.3 updates httpd.x86_64 2.2.15-69.el6.centos.4 updates httpd.x86_64 3.0.3-1.el6 epel
Step 2 ? Install the Required Version
Once we have identified the version we want to install then we can install it using the following command ?
yum install [package-name]-[version]
For example, to install version 3.0.3 of the Apache web server, we would run the following command ?
yum install httpd-3.0.3-1.el6
Output may look like this ?
Loaded plugins: fastestmirror Setting up Install Process Loading mirror speeds from cached hostfile * base: mirror.its.sfu.ca * extras: mirror.its.sfu.ca * updates: mirror.its.sfu.ca Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:3.0.3-1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved =========================================================================================================================================================== Package Arch Version Repository Size =========================================================================================================================================================== Installing: httpd x86_64 3.0.3-1.el6 epel 2.7 M Transaction Summary =========================================================================================================================================================== Install 1 Package(s) Total download size: 2.7 M Installed size: 6.3 M Is this ok [y/N]: y Downloading Packages: httpd-3.0.3-1.el6.x86_64.rpm | 2.7 MB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : httpd-3.0.3-1.el6.x86_64 1/1 Verifying : httpd-3.0.3-1.el6.x86_64 1/1 Installed: httpd.x86_64 0:3.0.3-1.el6 Complete!
In the above output you will see, the package manager resolves assurance and downloads the specified version of the package. Then, it installs the package and verifies its successful installation.
Using Apt-Get Package Manager
When we need to install a specific version of a package on the Ubuntu system, by using the apt-get package manager method. Apt-Get is a command-line package that manages utilities specially designed for Debian-based Linux systems like Ubuntu. To use Apt-Get command to install a specific package version, we follow these steps:
Step 1 ? List All Available Versions
To install a specific version of a package using Apt-Get, the first step is to list all available versions of the package using the following command ?
apt-cache showpkg [package-name]
For example, let's say we want to install version 2.7.18 of the Python programming language. we can write the following command ?
apt-cache showpkg python
The output will look something like this ?
Package: python Versions: 2.7.18-1ubuntu1.6 (/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_bionic-updates_main_binary-amd64_Packages) (/var/lib/dpkg/status) Description Language: File:/var/lib/apt/lists/us.archive.ubuntu.com_ubuntu_dists_bionic-updates_main_binary-amd64_Packages MD5: fbafe6f0b
Method 2: Using RPM or DEB Package Files
This method involves downloading and installing RPM or DEB package files. RPM is the package manager used in CentOS and but Ubuntu uses DEB.
First, let's talk about RPM package files. To install an RPM package file, you'll need to download the file from a trusted source. Once you have the file, you can install it using the following command ?
rpm -ivh [package-file-name].rpm
Here's an example. Let's say we want to install version 3.6.1 of the GIMP image editing software on my CentOS system, but it's not available in the default repositories. We have found an RPM package file called gimp-3.6.1.rpm and downloaded it to your Downloads directory then run the following command to install the package ?
sudo rpm -ivh gimp-3.6.1.rpm
The sudo command is used here because we need root privileges to install packages system-wide. The -ivh options tell the rpm command to install the package in verbose mode, which displays detailed information about the installation process, and to display progress bars during installation.
If the installation is successful, the terminal output will look something like this ?
Preparing... ################################# [100%] Updating / installing... 1:gimp-3.6.1-1 ################################# [100%]
Moving on to DEB package files, these are used in Ubuntu systems. Similar to RPM packages, you must first download the package file from a reliable source. After you have the DEB package file, you can install it using the following command ?
sudo dpkg -i vlc_2.4.3.deb
The sudo command is used here because we need root privileges to install packages system-wide. The -i option tells the dpkg command to install the package.
If the installation is successful, the terminal output will look something like this ?
Selecting previously unselected package vlc. (Reading database ... 234362 files and directories currently installed.) Preparing to unpack vlc_2.4.3.deb ... Unpacking vlc (2.4.3) ... Setting up vlc (2.4.3) ... Processing triggers for desktop-file-utils (0.24-1ubuntu3) ... Processing triggers for mime-support (3.59ubuntu1) ... Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
If you need a specific package version that is not available in your system's repository, Method 2 - using RPM or DEB package files - is a great alternative. However, it is important to download packages from trusted sources to avoid potential security risks that may arise from installing packages from unknown sources.
Conclusion
In conclusion, there are several methods for installing a particular package version in CentOS and Ubuntu, each with its own advantages and disadvantages. Method 1, using the package manager and specifying the version number, is the easiest and most straightforward method, but it relies on the package being available in the repository. Method 2, downloading and installing RPM or DEB package files, is a good option if the package is not available in the repository, but requires downloading packages from trusted sources.
Overall, it's important to be aware of these different methods and choose the one that best fits your needs and skill level. By following the steps outlined in this article, you should be able to successfully install a particular package version in CentOS and Ubuntu, no matter which method you choose.