How to Check CentOS Version

How to Check CentOS Version

Our post’s topic is the attractive CentOS distribution of Linux and how to check the version of CentOS on your system or server. CentOS, which stands for Community Enterprise Operating System, is a famous and beloved operating system among Linux users, which is used by almost 30% of all Linux web servers. CentOS is developed based on the source code of the Red Hat Enterprise Linux distribution. It provides a free enterprise-class computing platform and strives to make the binary language 100% compatible with its upstream source, Red Hat.

This operating system was developed up to version 8 and then stopped. Recently, with the discontinuation of CentOS8, the CentOs stream has become popular for users; of course, it should be noted that the CentOS 7 version can still be used. We have already talked about the CentOS operating system, you can learn more about the functionality and application of CentOS by reading our article.

Knowing the version of CentOS can be helpful for various purposes; the most common reason users look for the CentOS version is to ensure that their operating system is up-to-date. In many failures or problems, not using the latest version of the operating system is involved. It is also essential to know the version of CentOS to provide information to the support team and troubleshoot system problems. This article aims to guide you to be aware of the CentOS version of your Linux system. For this, we offer different methods so that you can do whatever is easier for you.

Instructions for checking the CentOS version


  • A system based on CentOS
  • Using the terminal window or command line (Ctrl-Alt-F2)

1.lsb command to view CentOS Linux version information

Standardizing the architecture of software systems is the goal of the LSB (Linux Standard Base), a joint effort between different Linux distributions. lsb release is a command that can be run from the command line to display full details of your OS version as output.

  1. Before you can use the lsb commands, you must first install the package. For this purpose, use the following command:
sudo yum install redhat-lsb-core
  1. Enter your sudo password and then press y and Enter to continue the installation.
  2. Type the following commands to access the complete information of the CentOS version:
  • lsb_release –d


Description:    CentOS Linux release 7.4.1708 (Core)

Note: In the description line, the version of CentOS is displayed.

  • lsb_release –r


Release:        7.4.1708
  • lsb_release –a


LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.4.1708 (Core)
Release:        7.4.1708
Codename:       Core

To understand version number 7.4.1708:

  • 7 represents the main branch of CentOS.
  • 7.4 represents the latest minor version of the CentOS7 distribution.
  • 1708 represents the date code of the minor version of CentOS; that is, it gives the release time of this version.

2. hostnamectl command to find CentOS version

The hostnamectl command, available in CentOS 7 and later, allows you to view or change the hostname and other configuration information. The uname -a file and the /etc/centos-release file contain contents to provide information related to the CentOS version. These files not only tell you what version of Linux your system is running but also let you know the Linux kernel version of your system. So To access this information, run the following command:



Static hostname: operavps
         Icon name: computer-vm
           Chassis: vm
            Machine ID: f9afeb75a5a382dce8269887a67fbf58
           Boot ID: 668b5c55c6b9438b9356438d8beceec6
    Virtualization: xen
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-693.21.1.el7.x86_64
      Architecture: x86-64

3. finding the CentOS version using RPM

Red Hat Package Manager, or RPM for short, is a free and open-source package manager designed for Red Hat Linux and its derivatives, such as RHEL, CentOS, and Fedora.

With the help of the rpm command, you can know the CentOS version as well as the centos-release package information and the names of the packages installed on your system. Therefore, to access these specifications, enter the following command:

rpm –qa centos-release

4. Access the CentOS version in the Release File

Every systemd-equipped computer has an /etc/os-release file that details the version of the operating system installed.

how to check CentOs version

Use the following command to access the release file and find the Linux distribution and the original version you are running:

cat /etc/os-release

As a result, you will get information about the originally released version, operating system name, and other details.


NAME="CentOS Linux"
VERSION="7 (Core)"
ID_LIKE="rhel fedora"
PRETTY_NAME="CentOS Linux 7 (Core)"


Note: This method of accessing the CentOS version works for the CentOS7 version.

To view the full release version, you can use the following command:

cat /etc/centos-release


CentOS Linux release 7.4.1708 (Core)

The result of this command will be information containing minor release number, major release number, and asynchronous release number.

In addition to the above commands, you can also use other commands to achieve the updated version of the CentOS/Redhat operating system:

  • /etc/redhat-release
  • /etc/system-release

5. finding the version of CentOS through programming

If you want to check the CentOS version through programming automatically, there are several methods. For this purpose, we explain two primary ways through Bash and Python programming languages:

  • Through the Bash script

If the /etc/centos-release file already exists and contains the CentOS version number, you can use the following bash script to access the CentOS version number.

full=`cat /etc/centos-release | tr -dc '0-9.'`
major=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f1)
minor=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f2)
asynchronous=$(cat /etc/centos-release | tr -dc '0-9.'|cut -d \. -f3)
echo CentOS Version: $full
echo Major Relase: $major
echo Minor Relase: $minor
echo Asynchronous Relase: $asynchronous

In a Bash script, you can change the encoding to your liking. You can use the sample script provided above as a guide.

  • Through Python programming language

The distribution name is displayed through the Python script that we provide below, in addition to the operating system’s version number. Before attempting to use Python to know the CentOS version, make sure that the python3-distro package is present on your system:

import distro

Also, Python code can be executed in a shell:

$ python3 -c 'import distro; print(distro.linux_distribution())'

How to check the Linux Running Kernel version

As important as knowing the release version of CentOS, knowing the version of the Linux kernel can be helpful. Find out your CentOS kernel version and operating system architecture by running the following command:

uname –r


We always recommend that you use the latest and newest version of CentOs because the latest updates come with more features, and their problems and bugs have been fixed; also, the efficiency and performance of the operating system have been improved compared to the old version.

CentOS, which stands for "Community Enterprise Operating System," is a free and open-source version of Linux. CentOS and Red Hat Enterprise Linux have the same performance because CentOS is developed based on RHEL. Also, CentOS is mostly employed for development and deployment.

CentOS 7 will be discontinued on June 30, 2024.


As the most popular Linux distribution in the web hosting industry, the CentOS operating system is the choice of most users after purchasing a Linux VPS. Knowing the version of CentOS is helpful for Linux users for various reasons; in this article, we have tried to guide you in this field by providing different methods to access the details of the CentOS version as well as the awareness of the CentOS kernel version; so that you can obtain information about the CentOS version through any method that is easier for you.

We hope the tutorial on checking the CentOS version is informative and helpful for you; if you have any questions in this field, share them with us in the comments section.

Leave a Reply

Your email address will not be published. Required fields are marked.