4 Ways to Check the CentOS Version

One of the basic things a Linux user should know for troubleshooting issues is what version or release of Linux OS is currently on the device. Several problems that you may encounter related to bugs or dependencies related errors may depend on an OS version or kernel version. Similarly, knowing the version number confirms the availability of certain features of OS and software compatibility, which makes system administration tasks very easy. In this article, we will show you different methods to determine the OS and kernel version of CentOS.

Checking the CentOS version and other details

We need to know two major things while running Linux:

  1. OS update level
  2. Running kernel version

Method 1: Check Update Level

First of all, we have to make sure that we are using the CentOS distribution of Linux. To confirm that we will look into /etc/os-release file by using below command:

$ cat /etc/os-release

Here is a sample output:

tuts@fosslinux:~ $ cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
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"

So now we are sure that we have CentOS. Next, we will look into /etc/centos-release file by using the cat command. This will show a full release version of your CentOS.

$ cat /etc/centos-release

Sample Output:

CentOS Linux release 8.2.2004 (Core)

Method 2: Using hostnamectl command

One of the simplest ways of getting CentOS version information is by using ‘hostnamectl’ command, as shown below:

$ hostnamectl

Sample Output:

Static hostname: fosslinux
         Icon name: computer-vm
           Chassis: vm
        Machine ID: gty77da6a1764e07be909d7cf65t6d66
           Boot ID: dyu34u3dc549484c8927e830e198yt56
    Virtualization: kvm
  Operating System: CentOS Linux 8 (Core)
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-193.x86_64
      Architecture: x86-64

Method 3: Using rpm command

You can also query ‘centos-release’ package using the rpm command to extract the full release version of CentOS:

$ rpm -qa centos-release

Sample Output:

centos-release-8-2.2004-x86_64

Method 4: Using Kernel Version

Another way to find the exact CentOS version is first to get the Linux kernel version and then search that kernel version in the CentOS Wikipedia. It will show you the correct CentOS version against the kernel version. If you ask me why this method? It’s handy to know the CentOS release date, RHEL release date and other details in a table view so that you know more about your CentOS version and where it stands concerning the versions officially released.

$ uname -r

Sample Output:

4.18.0-193.x86_64

Now you can copy the kernel version and search in CentOS latest version table on Wikipedia page.

centos version by kernel version
centos version by kernel version

Conclusion

Those were the four methods to fetch the CentOS, kernel version, and other essential details of your system. As a system administrator, these commands should be on the top of your list for troubleshooting problems.

Leave a comment

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