How to Check Version of CentOS

Red Hat Enterprise Linux or RHEL in short is a commercial Linux based operating system. RHEL provides paid support for its customers. While most of the softwares used in RHEL is the same as the standard versions of these software found in other Linux distributions such as Ubuntu/Debian, RHEL only gives support for these software.

A commercial Linux distribution like RHEL is very stable as only old, stable and thoroughly tested software are distributed. RHEL also has long term support for all its releases. So it is ideal for small, medium and big companies and institutions.

CentOS is another Linux distribution which has the same codebase as RHEL and is freely distributed. It’s free to download and use. The only downside is that it does not have paid support. Basically you are responsible for fixing any problem you may have with your operating system. You can’t ask Red Hat or CentOS to fix them for you. So CentOS is RHEL without paid support.

There are many version of CentOS available, for example, CentOS 5, CentOS 6, CentOS 7. CentOS 7 is the latest version of CentOS and it is based on RHEL 7. CentOS 6 is an earlier version of CentOS which is based on RHEL 6, and is still supported till November 30, 2020 according to the official website of CentOS at the time of this writing. CentOS 5 and earlier is at the EOL (End of Life) and you will not get any updates or bug fixes any more.

Since you will have to fix all the problems you face while using CentOS, the version of CentOS you’re using is a must have knowledge. If you can’t tell which version of CentOS you’re using, getting help from online forums and other places would be really hard for you.

You will also need to know which version of CentOS you’re using while installing new software. For example, NodeJS has packages for CentOS 6 and CentOS 7. To install it on CentOS 6, you must follow the procedures for CentOS 6 given on the official website of NodeJS. To install it on CentOS 7, you will be following instructions for CentOS 7 the same way. Otherwise things won’t work as expected.

Now you can tell how important it is to actually know the version of CentOS you’re using. In this article, I will show you ways of checking version of your CentOS operating system. Let’s get started.

Using the cat Command:

The CentOS release information is stored in the /etc/redhat-release file on CentOS and RHEL. The easiest way to check CentOS version is to read that file with the following command:

$ cat /etc/redhat-release

As you can see, the version information is printed. I am using CentOS 7.4.

Using lsb_release Command:

You can check CentOS version with the widely used lsb_release command as well. But there is a slight problem with this command on CentOS and RHEL operating systems. The command is not available by default. Because, on CentOS and RHEL systems, the redhat-lsb-core package is not installed.

You can easily install it with the following command:

$ sudo yum install redhat-lsb-core -y

The package should be installed.

Now run the following command to check version of your CentOS operating system:

$ lsb_release -a

As you can see, the correct CentOS version is printed. I am using CentOS 7.4.

So that’s how you check the version of your CentOS operating system. Thank you for reading this article.

About the author

Shahriar Shovon

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.