There are several ways on how to check what version of CentOS is running on your VPS/Dedicated server. The simplest way to check for the CentOS version number is to execute the cat /etc/centos-release command in console via SSH. Checking a CentOS version very important for all server operations so commands are different from one to another CentOS system.
Commands in console to check CentOS version
The following commands are recommended ways on how to check CentOS version on your CentOS Linux VPS or dedicated server:
$ rpm -q centos-release
CentOS version valid for CentOS 6 and higher. Causes to reveal major, minor and asynchronous CentOS version.
$ lsb_release -d
Version check. This command requires redhat-lsb package to be installed before execution.
$ 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.
How to check CentOS 7 version
In CentOS version 7 and above you may use ‘hostnamectl’ command might provide you with a detailed and significant reporting information about your OS version number:
And the sample output:
$ hostnamectl Static hostname: example.com Icon name: server-018-DS Chassis: vm Machine ID: fe069af6a0939e07be909d7cf32add99 Boot ID: b81bb73dc739649c8927e830e149eb55 Virtualization: kvm Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-862.6.3.el7.x86_64 Architecture: x86-64