How to Check your CentOS Version

Introduction

Before doing any work on a CentOS machine for the first time, you should check what version of CentOS is installed.

In this tutorial, we'll show you how to verify what version of CentOS is installed on your system using several distinct commands.

CentOS Linux has three primary active released branches at the time of writing: CentOS 5, CentOS 6, and CentOS 7.

Check CentOS version from the Command Line

The lsb_release tool shows information about your Linux distribution's Linux Standard Base (LSB).

This is the preferable technique, and it should work regardless of CentOS version.

Type the following command into your terminal:

lsb_release -a

If you got an error like:

Output

-bash: lsb_release: command not found

Fix this by installing the following package:

sudo yum install redhat-lsb-core -y

The Description line will display your CentOS version. I'm running CentOS Linux release 7.9.2009 as you can see from the results.

What does the 7.9.2009 version number mean?0

  • 7 is the major CentOS branch.
  • 7.9 is the latest minor version of CentOS 7.
  • 2009 is the date code of the minor version, 2009 means September 2020. This number is used to signify the date of the release.
ℹ️
If you get a message saying bash: lsb_release: command not found..., it means that the package redhat-lsb-core is not installed on your system. You can easily install it with: sudo yum install redhat-lsb-core.

Alternative methods to check CentOS version

Check CentOS version using the rpm command

Red Hat Package Manager rpm is a package management application for Red Hat-based systems including RHEL, CentOS, and Fedora.

To view information about the centos-release package, which has the CentOS version in its name, use the rpm tool:

rpm --query centos-release
Output

centos-release-7-5.1804.4.el7.centos.x86_64

Check CentOS version using the /etc/centos-release file

The /etc/centos-release file is provided by the centos-release package.

Enter the following command to determine your CentOS version:

cat /etc/centos-release
Output

CentOS Linux release 7.5.1804 (Core)

Check your CentOS version using the /etc/os-release file

All systems running systemd have a file called /etc/os-release that contains information about the operating system.

Only CentOS 7 is required for this strategy to work:

cat /etc/os-release
Output

NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="

Check your CentOS version using the hostnamectl command

You may use hostnamectl to set the system hostname, but you can also use it to locate your CentOS branch.

Only CentOS 7 will work with this method:

hostnamectl
Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 2849f743fbe74706abaa6cb8b2ae5377
           Boot ID: 8259a43c6265465884920ac6d762ed5e
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-862.9.1.el7.x86_64
      Architecture: x86-64

FAQs to Check your CentOS Version

What does the command "cat /etc/redhat-release" display?

Executing the command "cat /etc/redhat-release" displays the specific version of CentOS installed on your system.

Is there any other command to check the CentOS version?

Yes, you can also use the command "lsb_release -a" to retrieve detailed information about the CentOS version.

How do I identify the CentOS release using the command "lsb_release -a"?

Executing the command "lsb_release -a" provides output containing CentOS release details, including the version number and other information.

Will the command "rpm -q centos-release" work to check the CentOS version?

Yes, running the command "rpm -q centos-release" in the terminal will display the CentOS version installed on your system.

What if the command "cat /etc/redhat-release" displays a different version than I expected?

If the displayed version differs from your expectations, you might have a different CentOS version or a modified /etc/redhat-release file.

Can I check the CentOS version graphically through the settings?

Yes, you can check the CentOS version graphically by navigating to "Settings" and selecting "Details" or "About" to view the system information.

Is it possible to check CentOS version using the "uname" command?

No, the "uname" command provides information about the kernel, not the CentOS version. Use the mentioned commands for CentOS version verification.

Conclusion

In this tutorial, we have shown you how to find the version of CentOS installed on your system.

Visit the Wiki CentOS Releases page for additional information about CentOS releases.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.