Brief: This article explains several ways you can check the version of CentOS Linux distribution running on your machine.
CentOS is a great OS when comes to server software due to the fact that they have longer support cycle and great stable software in the repositories and a larger community. To know more about why CentOS is better, check out this page.
It happens most of the times when installing or selecting a software package, one needs to know the version of the CentOS running in their systems to avoid dependency mismatch and other issues.
In this tutorial, I’ll show you some of the ways by which you can check the version of the CentOS.
How to Check CentOS Version
Before we see the methods to check CentOS version, let’s first understand the version number and what those number means.
CentOS version consists of three parts, which can be best understood with an example. Consider the version:
- 7-major release: This is the most important version number because software packages developed for one version may not be supported in other versions. This is because newer versions will have some bugs fixed which are not in new versions and also they will have new features, new packages, and new hooks into the system. So there will be a problem when running the software intended for other versions and hence can mess up the system
- 14-minor release: These are less important but they are crucial for maintaining major security updates and a few new features.
- 1234-build number: This is a version for distributing the software with minor security updates and bug fixes. This doesn’t affect the software versions running on the system that much.
Method 1: Using hostnamectl
The hostnamectl command can be used to query and set the hostname for the system. I also display the Version number of the OS running in the system. This Command displays only the major version number.
Your output will be similar to like the one below.
Method 2: Using rpm package manager
Since os itself considered as a package by most package managers one can query the package manager(rpm in this case) to find the version of the OS.
rpm -q centos-release (or) rpm --query centos-relase
- rpm is the package manager
- -q or –-query is the option for querying
- centos-release is the package that we want to query on
Note: If you need to check any other software replace centos-release with <packagename>.
Result of the above will be similar to the one below:
Way 3: Refer the files /etc/*release
Every Linux OS hosts teh important and configuration details about itself and packages in /etc/ directory. And so does centOS.
If you issue
ls /etc/*release , following files will be listed.
One can guess by the name of the files, they carry information about the system release. You can manually open the files using any text editor and examine the files for version information or cat command can be used to see the contents of the files. If you don’t know what is
cat or you want to brush up your
cat skills, Check out this page.
Result of the command will be similar to below:
Way 4: Using lsb_release tool
lsb release command displays important lsb(linux standard base) information and distribution information. But this tool is available inside the package redhat-lsb. Install the package in your system using the below command to continue (if you don’t have already).
sudo yum install redhat-lsb
As you might have noticed, you need to be a sudoer for running this command as you are installing a package. If you are a sudoer and you want to give someone sudoer rights, Checkout out this page. If you are not a sudoer, try contacting your system admin.
After installing the package, run the below command:
- -d is the option to display a description of the OS
Result will be similar to the one below:
Congratulations!. You have made it to the end. By now, you know various ways by which version number of the CentOS can be found.
I hope you found this article useful. If you have any suggestions or comments, feel free to drop them below.