How to Find Your CentOS Version

Knowing your CentOS version is important for various system administration tasks. You may need to verify compatibility before installing certain software programs. Or you might need to look up specifics about a release before upgrading to CentOS. Fortunately, there are a few quick commands to find your CentOS version.
Check /etc/centos-release File
The simplest way to find your CentOS version is by checking the /etc/centos-release file. This contains version information in an easy-to-read format.
To view the file, use:
cat /etc/centos-release
On CentOS 7, you'll see details like:
CentOS Linux release 7.9.2009 (Core)
And on CentOS 8:
CentOS Linux release 8.4.2105
This quickly shows your major and minor version numbers.
Use the uname Command
The uname command also provides version details. The -r flag prints the kernel release number. This often aligns with CentOS major versions.
Run:
uname -r
Example output on CentOS 7:
3.10.0-1160.15.2.el7.x86_64
And CentOS 8:
4.18.0-305.10.2.el8_4.x86_64
So the first number indicates if you have a CentOS 7 or 8 system.
Check With redhat-release
As CentOS is built from Red Hat Enterprise Linux (RHEL) sources, the redhat-release command displays similar version info:
redhat-release
On CentOS 7:
CentOS Linux release 7.9.2009 (Core)
And CentOS 8:
CentOS Linux release 8.4.2105
This matches the /etc/centos-release output.
Use rpm to Query System Release Packages
The RPM database includes version info as well. Query release packages with:
rpm -q centos-release
rpm -q redhat-release
CentOS 7 output:
centos-release-7-9.2009.0.el7.centos.x86_64
CentOS 8:
centos-release-8.5-1.2111.el8.x86_64
redhat-release-8.5-1.el8.x86_64
So RPM provides the full release package string including minor version info.
Check /etc/os-release File
For programmatic access, check /etc/os-release. This contains distro identification details in a key=value format:
cat /etc/os-release
Relevant CentOS version lines:
VERSION="7 (Core)"
VERSION_ID="7"
And CentOS 8:
VERSION="8 (Core)"
VERSION_ID="8"
So this provides a major version in a parseable format for scripts or tools.
Conclusion
Finding your CentOS version is easy using several built-in commands and files. Simple options like cat /etc/centos-release or uname -r provide a quick way to manually spot your major/minor release details. For coding, /etc/os-release stores the distro version in a key=value format. So take your pick of these handy tools next time you need to verify or look up the CentOS version.






