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.

Updated: 09 May, 23 by Antoniy Yushkevych 10 Min

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.

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.

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

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.

  1. Major Version: 9 is the major release version number.
  2. Minor Version: 2 is the minor release version number.
  3. Monthstamp: codebase month October and year timestamp is 2020.

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:

cat /etc/redhat-release

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:

cat /etc/centos-release

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:

cat /etc/system-release

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:

lsb_release –d

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:

cat /etc/os-release

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:

rpm -E %{rhel}

You will see:

8

You can also use the following command:

rpm --eval %{centos_ve}

The output will be the same as before:

7. rpm query

Use rpm CentOS release to know the answer to your question.

Type:

rpm -q centos-release

The output will be as follows:

centos-release-8.1-1.1911.0.8.el8.x86_64

8. hostnamectl command

You can use the hostnamectl command in the following way to get the system information:

hostnamectl

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:

# uname -s -r

Output:

Linux 3.10.0-693.21.1.el7.x86_64

Input:

# uname -a

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:

# uname –v

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)

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.

  1. 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.

import platform

  1. Use the platform module to get the CentOS version

Use the platform.linux_distribution() function to get the distribution information.

centos_version = platform.linux_distribution()

  1. 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.

version_number = centos_version[1]

  1. Print the CentOS version number

Use the print() function to display the CentOS version number.

print(CentOS version:, version_number)

Full code:

import platform

centos_version = platform.linux_distribution()

version_number = centos_version[1]

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:

  1. Open a terminal window.
  2. 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.
  3. Use a text editor such as Vim or Nano to open the new file. For example, vim check-centos-version.sh.
  4. Start the script with the shebang line, which specifies the interpreter for the script. In this case, use #!/bin/bash.
  5. Add the command for checking the CentOS version to the script. For example, cat /etc/redhat-release.
  6. Save the changes to the script and close the text editor.
  7. Make the script executable by running chmod +x check-centos-version.sh.
  8. Run the script by typing ./check-centos-version.sh. This will display the CentOS version installed on your system.

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.

People are also reading:

Antoniy Yushkevych

Antoniy Yushkevych

Master of word when it comes to technology, internet and privacy. I'm also your usual guy that always aims for the best result and takes a skateboard to work. If you need me, you will find me at the office's Counter-Strike championships on Fridays or at a.yushkevych@monovm.com