How to determine CentOS version?

In cases like CentOS the actual version is usually placed in /etc/*elease.

cat /etc/*elease

granted this file usually holds the version of the entire OS minus the kernel (since you can choose which to load). This file will have the same information as /etc/issue but with CentOS instead of RedHat


As you can see in /etc/issue, you're using CentOS 5.3. (It says Red Hat because CentOS is based upon the RH sources, and some software checks /etc/issue to identify the distro in use; thus, they'd fail if this was changed to CentOS).

The 4.1.2-4 in /proc/version refers to the version of the gcc C compiler used to build the kernel.


The most reliable way of finding MAJOR version of CentOS (5 or 6 etc) is:

# rpm -q --queryformat '%{VERSION}' centos-release
6

For RHEL do this:

# rpm -q --queryformat '%{RELEASE}' redhat-release-server | awk -F. '{print $1}'
7

The only portable way of finding out a version without lsb_release or other tools is:

# grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release
6.5

Tags:

Centos

Version