4 Ways to Check CentOS or RHEL Version
Do you know the version of CentOS/RHEL release you are running on your server? Why is this even important? There are several reasons to keep this information in mind: to quickly gather information about your system; keep up with bug fixes and security updates, and configure correct software repositories for a specific release, among others.
This is probably an easy task for experienced users, but it’s not usually the case for newbies. In this article, we will show how to check the version of CentOS or RHEL Linux installed on your server.
How to Check Linux Kernel Version in CentOS
Knowing the kernel version is just as important as knowing the distro release version. To check Linux kernel version, you can use the uname command.
From the output of the above command, the CentOS is powered by an old kernel version, to install or upgrade to the latest kernel release, follow the instructions in our article: How to Install or Upgrade to Kernel 4.15 in CentOS 7.
How to Check CentOS or RHEL Release Version
CentOS release version numbers have two parts, a major version such as “6” or “7” and a minor or update version, such as or “6.x” or “7.x”, which correspond to the major version and update set of RHEL receptively, used to build a particular CentOS release.
To elaborate more in this, take for instance CentOS 7.5 is built from the source packages of RHEL 7 update 5 (also known as RHEL version 7.5), which is referred to as a “point release” of RHEL 7.
Let’s take a look at these 4 useful ways to check CentOS or RHEL release version.
1. Using RPM Command
RPM (Red Hat Package Manager) is a popular and core package management utility for Red Hat based systems like (RHEL, CentOS and Fedora), using this rpm command, you will get your CentOS/REHL release version.
2. Using Hostnamectl Command
hostnamectl command is used to query and set Linux system hostname, and show other system related information, such as operating system release version as shown in the screenshot.
3. Using lsb_release Command
lsb_release command displays some LSB (Linux Standard Base) and distribution information. On CentOS/REHL 7, the lsb_release command is provided in the redhat-lsb package which you can install it.
Once you have installed it, you can check your CentOS/REHL version as shown.
4. Using Distro Release Files
All the above commands retrieve OS release information from a number of system files. You can view the contents of these files directly, using the cat command.
That’s all for now! If you know any other method that should be covered here, let us know via the comment form below. You can also ask any questions related to the topic.
How To Check CentOS Version? [Latest CentOS Version]
Read this article to learn how to check CentOS version and find out what the latest CentOS version is. You’ll also learn the Linux command to check CentOS version.
List of content you will read in this article:
There are many reasons for a computer administrator to know about an operating system version that they are running on their computer or server. These reasons can be for:
- Can a certain program be installed?
- How to fix a specific error?
- Should the OS be updated to a newer version?
These questions people can ask you to know the version of the operating system on your machine. There is the easiest way to know about the current version of CentOS you are using with cat /etc/centos-release command. In this tutorial, we are teaching you how to check CentOS version. Before moving on, let’s dive head-first into knowing about CentOS version.
What is CentOS? [Definition]
CentOS is a free community support platform for computing that is based on Linux. Red Hat Enterprise joined officially with Linux in 2014. This open-source operating system is famous among administrators, DevOps engineers, and even among general users at home. However, CentOS is most commonly used among many organizations for development and production purposes.
Features of CentOS
- Perform common everyday tasks.
- Use the Linux command line.
- Get a firewall.
- Get a web server.
- Folders sharing and running.
- Security-enhanced Linux (SELinux).
- Additional level security.
These features among many others make CentOS a very attractive platform for users from many different fields of IT and cybersecurity, as well as general computer users.
Why do you need to Check CentOS Version?
As mentioned previously, there are a lot of reasons why you will need to check CentOS version, however, the most common ones are as follows:
- When you want to troubleshoot your system for some error, you have to get centos version of your system to look for the compatible app or problem solution pack.
- When you want to keep your system up-to-date.
- When you want to save your system from potential security risks, you need an updated firewall for flawless protection.
- If you are new to using CentOS and need some expert advice from the internet, you need to mention the OS version you are using on your system.
- When you will need to run a disk cleanup.
- There are frequent updates launched at particular times for CentOS, if you don’t know about the current version you are using on your system you won’t be able to know when and how to update centOS.
- When adding extra IPs to a VPS server
How to get CentOS Version Number?
The CentOS version has three parts. For example: if you see the following information in the version part. 9.2.2010
The explanation would be as follows.
- Major Version: 9 is the major release version number.
- Minor Version: 2 is the minor release version number.
- Monthstamp: codebase month October and year timestamp is 2020.
How to check CentOS version using Command Line
So, let’s discuss how to check centos version you are using on your system. There are various ways, and you can use any of them to find out the version.
1. /etc/redhat-release file
The RedHat Linux distribution file also contains information about the version. To get the information, type the following Linux command:
The following output is all you want:
CentOS Linux release 8.1.1911 (Core)
2. /etc/centos-release file
For the CentOS specific file type:
The output will be as follows:
CentOS Linux release 8.1.1911 (Core)
3. /etc/system-release file
Type the following command to look for the version of CentOS:
You will have the following output:
CentOS Linux release 8.1.1911 (Core)
4. lsb_release command
You will need to install this command into your OS because this command doesn’t come preinstalled in your OS.
Write the following:
yum install redhat-lsb
Then type this command:
You will see the following output:
Description: CentOS Linux release 8.1.1911 (Core)
5. /etc/os-release file
When you want to know about the major version of your OS you need to type the following command:
The output you get will be detailed information regarding major serials and numbers, and will look something like this:
NAME=»CentOS Linux»
VERSION=»8 (Core)»
ID=»centos»
ID_LIKE=»rhel fedora»
VERSION_ID=»8″
PLATFORM_ID=»platform:el8″
PRETTY_NAME=»CentOS Linux 8 (Core)»
ANSI_COLOR=»0;31″
CPE_NAME=»cpe:/o:centos:centos:8″
HOME_URL=»https://www.centos.org/»
BUG_REPORT_URL=»https://bugs.centos.org/»
CENTOS_MANTISBT_PROJECT=»CentOS-8″
CENTOS_MANTISBT_PROJECT_VERSION=»8″
REDHAT_SUPPORT_PRODUCT=»centos»
REDHAT_SUPPORT_PRODUCT_VERSION=»8″
6. rpm macro
This simplest macro evaluation is enough to give you the right answer as well. Just type:
You can also use the following command:
The output will be the same as before:
7. rpm query
Use rpm CentOS release to know the answer to your question.
rpm -q centos-release
The output will be as follows:
8. hostnamectl command
You can use the hostnamectl command in the following way to get the system information:
Here is the output:
Static hostname: localhost.localdomain
Transient hostname: li1176-240.members.linode.com
Icon name: computer-vm
Chassis: vm
Machine ID: c2a4bfa7e0c74457b3a978656ab959e8
Boot ID: c89bae2d3ec7493987a455bfa15e4818
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1062.12.1.el7.x86_64
Architecture: x86-64
To see only the OS version, type:
hostnamectl | grep «Operating System»
And you will see:
Operating System: CentOS Linux 7 (Core)
9. Running Kernel version
When you want to know about CentOS kernel architecture, use one of the following ways:
Input:
Output:
Input:
Output:
Linux geeklab 3.10.0-693.21.1.el7.x86_64 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Kernel Compile Time
(uname -v) with known value:
Input:
Output:
#1 SMP Wed Mar 7 19:03:37 UTC 2018
10. Check with GRUB configuration files
This is the most uncommon way to check CentOS version on your system.
CentOS 7 Example
Input:
# cat /boot/grub2/grub.cfg | grep -w menuentry
Output:
menuentry ‘CentOS Linux (3.10.0-693.21.1.el7.x86_64) 7 (Core)’ —class centos —class gnu-linux —class gnu —class os —unrestricted $menuentry_id_option ‘gnulinux-3.10.0-693.21.1.el7.x86_64-advanced-0f790447-ebef-4ca0-b229-d0aa1985d57f’ <
menuentry ‘CentOS Linux (3.10.0-693.17.1.el7.x86_64) 7 (Core)’ —class centos —class gnu-linux —class gnu —class os —unrestricted $menuentry_id_option ‘gnulinux-3.10.0-693.17.1.el7.x86_64-advanced-0f790447-ebef-4ca0-b229-d0aa1985d57f’ <
Another version for the grub file:
Input:
# grep saved_entry /boot/grub2/grubenv
Output:
saved_entry=CentOS Linux (3.10.0-693.21.1.el7.x86_64) 7 (Core)
CentOS 6 Example
Input:
# cat /boot/grub/grub.conf | grep title
Output:
title CentOS (2.6.32-696.20.1.el6.x86_64)
title CentOS (2.6.32-696.18.7.el6.x86_64)
Using Programming to Check CentOS Version
Python Programming
If you are looking to check CentOS version using Python programming, here is a step-by-step guide on how to do it.
- Import the necessary modules
Firstly, import the platform module. This module is a built-in module in Python that allows you to get information about the operating system you are running.
- Use the platform module to get the CentOS version
Use the platform.linux_distribution() function to get the distribution information.
- Extract the CentOS version number
The platform.linux_distribution() function returns a tuple with three values: the distribution name, version number, and code name. To get only the version number, use tuple indexing.
- Print the CentOS version number
Use the print() function to display the CentOS version number.
print(CentOS version:, version_number)
print(CentOS version:, version_number)
Bash Scripting
Bash scripting is a powerful tool for automating tasks in Linux, and checking the CentOS version installed on your system is no exception. Writing a simple Bash script lets you quickly and easily get the details you need about your CentOS version.
Here is a step-by-step guide to using Bash scripting to check CentOS version:
- Open a terminal window.
- Create a new file using the touch command. For example, you can use touch check-centos-version.sh to create a new Bash script file.
- Use a text editor such as Vim or Nano to open the new file. For example, vim check-centos-version.sh.
- Start the script with the shebang line, which specifies the interpreter for the script. In this case, use #!/bin/bash.
- Add the command for checking the CentOS version to the script. For example, cat /etc/redhat-release.
- Save the changes to the script and close the text editor.
- Make the script executable by running chmod +x check-centos-version.sh.
- Run the script by typing ./check-centos-version.sh. This will display the CentOS version installed on your system.
Conclusion
Throughout this blog, we have given you the most common and uncommon ways to check CentOS version of Linux and Kernel that you have installed on your system. Let us know how these steps have helped you figure out how to check CentOS version.
4 Ways to Check CentOS Version in Linux Command Line
Here are 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 because 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 time 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 ways by which you can check the version of the CentOS.
How to Check CentOS Version
To check CentOS version, you can use a command like this:
The result will give you the CentOS version number.
Before we see other 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.14.1234
- 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.
hostnamectl displays the major version number
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 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:
rpm command to query the system for version info
Method 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.
- centos-release
- os-release
- redhat-release
- system-release
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 detailed guide on using cat command.
Result of the command will be similar to below:
examine /etc/*release files for version information
Method 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).
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, learn how to create sudo user. 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
The result will be similar to the one below:
using lsb_release to find version information
This lsb_release command can be used in other distributions as well. For example, you can run it in Debian to check the Debian version.
Congratulations!. 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.
How To: 5 Ways to Check CentOS Version
Screenfetch running in CentOS 8
One of the very first questions a Linux user asks is about confirming the release (OS version) in use. Knowing release helps with highlighting software dependencies and compatibilities, confirms availability of certain features in your OS and simplifies the process of system administration – certain releases have a preferred set of commands for day-to-day management.
With CentOS being a rather popular server grade Linux distro, I can see that many visitors of my blog look for the same guidance quite regularly: check CentOS version. This article introduces 5 of the most common ways to do just that.
1. Inspect /etc/system-release
Just to be super sure that you’re actually looking at a CentOS distribution of Linux, I suggest you start with the /etc/os-release file. As shown below, it will help you with confirming your Linux distro and its major release version (CentOS and 7 in my case):
Now that we’re sure it’s CentOS, let’s look into the /etc/centos-release file – this will show you the full release version of your operating system:
Interesting: if you’re coming from RedHat infrastructure, you’d normally be looking for /etc/redhat-release file. That’s okay and the good news is this will still work in CentOS:
In fact, if you look at the /etc/redhat-release file on a CentOS server closely, you’ll notice that it is a symbolic link to /etc/centos-release:
2. Use hostnamectl to confirm Linux release
Provided that you’re running a recent enough version of Linux, you should have the hostnamectl command installed.
Among other things, hostnamectl provides easy access to the OS release information and Linux kernel version:
3. Confirm CentOS version with rpm
Next option you have is to use the RPM package manager to query a special package named centos-release. It will include the exact CentOS release version right in its full package name:
if you’re using RedHat, just do the same for the redhat-release package.
4. Confirm CentOS version using Linux kernel version
There are many ways to confirm your Linux kernel version, like uname command:
Using the kernel version number – 3.10.0-693 in my example – you can confirm the CentOS release using one of the public version information pages, like the CentOS wikipedia page.
Once you browse to the CentOS wikipedia page, just search for the kernel version number and it should find something like this for you, confirming CentOS version to be 7.4-1708:
CentOS 7 Release dates
CentOS 8 Release dates
5. Use lsb_release command to confirm Lunux release
Linux Standard Base (LSB) is a joint project by major Linux vendors to standardise configuration and usage of Linux distros. Amonth other things, it provides the lsb_release command that can help you check CentOS version.