In this tutorial, we will show you how to check the CentOS version from the command line. As a system administrator, the first question you should ask yourself after getting a new CentOS server to manage is what version of CentOS am I running? The version of the operating system in use on our server is important as it is critical that we have all the latest updates to ensure that the server is secure. There are a few ways to check your VPS hosting is using what version of CentOS. With the commands below you can choose one of them to find out which CentOS version is running on your system.
Check CentOS Version
There are several ways on how to check what version of CentOS is running on your system. Below you can find multiple examples on how to determine the CentOS version.
$ cat /etc/redhat-release CentOS release 7 (Final)
You can also use the command “
hostnamectl” to find OS version information in CentOS systems. For example:
$ hostnamectl Static hostname: kvm.idroot.us Pretty hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: 3974b10a7fa4421690c2e672917e00b0 Boot ID: 04fb94c0eff94c4ba5a543e085e09ccd Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-325.22.2.el7.x86_64 Architecture: x86-64
Another file that contains the centos version information is
$ cat /etc/issue CentOS release 7 (Final) Kernel \r on an \m
The rpm command can also be used to query for the centos version information:
$ rpm -q centos-release centos-release-7.el7.centos.10.x86_64
Another alternative is to use the
lsb_release the command is not available on centos by default. It can be installed by installing the RedHat LSB packages from the base repository:
yum install redhat-lsb -y
$ lsb_release -d Description: CentOS Linux release 7.1.1503 (Core)
Another method, you can use bash script can be used to obtain the CentOS version. The below script serves as an example:
#!/bin/bash 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
Save and close the file, then run:
CentOS Version: 8.4.2105 Major Relase: 8 Minor Relase: 6 Asynchronous Relase: 2105
Congratulations! You have successfully checked the CentOS version. Thanks for using this tutorial for the check CentOS version system. For additional help or useful information, we recommend you check the official CentOS website.