Check CentOS Version - Using Different methods ?

To know the exact kernel version or OS version is sometimes necessary while troubleshooting an issue or providing information to the support team. Therefore, it is a good idea to know the version of the system on which you are working. There are different ways to check CentOS version. CentOS release version has three major parts major release version, minor release version, and data code version. 

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Linux System related queries.

In this context, we shall look into different methods to know the CentOS version.

How to Check CentOS version via the Command Line ?

It is preferred to check version using command line as it is not depend on anything. So here we are going to check CentOS version using lsb_release (Linux Standard Base) utility. Generally, this method is best because it will work regardless of any desktop environment or version you are using.

To do this, Open your terminal and type the following command:

$ lsb_release -a

It will show output as below:

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 8.0 (Core)
Release:        8.0
Codename:       Core

In above output you can see that Description line is showing OS version. Currently, we are using CentOS Linux release 8.0.

How to Check CentOS Version Using RPM Command ?

rpm (Red Hat Package Manager) is a package management tool for CentOS, Fedora and Red Hat Enterprise Linux which are based on Red Hat.

You can use below command to get CentOS version using rpm tool:

$ rpm --query centos-release

How to Check CentOS version using /etc/centos-release file ?

You also can get version using centos-release file which is located at /etc/centos-release. It contains package information in CentOS.

$ cat /etc/centos-release

The output should look like:

CentOS Linux release 8.0 (Core)

How to Get Version using /etc/os-release file ?

You also can check version using os-release file. It contains identification data of operating system and this available only with newer CentOS distribution. This method will work if you have CentOS 8.

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

How to Check CentOS Version using hostnamectl command ?

Generally, hostnamectl command is used to set hostname in CentOS systems but you also can check the system details using it. Execute below command:

$ hostnamectl
Static hostname: local.linuxapt
    Pretty hostname: Linuxapt's Server
          Icon name: computer-vm
            Chassis: vm
         Machine ID: 44dddc11e56e403d8053ecdf0b92d462
            Boot ID: 615f6cb9fc2e4903818a192eddb860bc
     Virtualization: kvm
   Operating System: CentOS Linux 8 (Core)
        CPE OS Name: cpe:/o:centos:centos:8
             Kernel: Linux 3.10.0-957.5.1.el7.x86_64
       Architecture: x86-64

[Need assistance in fixing Linux System errors? We can help you. ]


This article covers how to get CentOS version using different methods. There are several ways on how to check what version of CentOS is running on your system. The simplest way to check for the CentOS version number is to execute the cat /etc/centos-release command. Identifying the accurate CentOS version may be required to help you or your support team to troubleshoot your CentOS system.

Different commands to check CentOS version:

  • $ rpm -q centos-release - CentOS version valid for CentOS 6 and higher. Causes to reveal major, minor and asynchronous CentOS version.
  • $ lsb_release -d - Requires redhat-lsb package to be installed before execution.
  • $ rpm -E %{rhel} - RPM macro to reveal a major CentOS version.
  • $ rpm --eval %{centos_ver} - RPM macro to display a major version of CentOS.
  • $ cat /etc/centos-release - Linux cat command to output content of the /etc/centos-release .to query CentOS version. Works with CentOS 6 and higher.