Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
4 Ways to Check CentOS or RHEL Version
If you're using CentOS or RHEL (Red Hat Enterprise Linux), knowing your system version is essential for package management, troubleshooting, and security updates. There are several reliable methods to determine which version you're running.
This article covers four effective methods to check your CentOS or RHEL version, each with step-by-step instructions and example outputs.
Method 1: Check /etc/redhat-release File
The /etc/redhat-release file contains version information about your CentOS or RHEL system, including the release number and update level. This is the most straightforward method.
To check the contents of the /etc/redhat-release file:
cat /etc/redhat-release
Example output for CentOS:
CentOS Linux release 7.9.2009 (Core)
Example output for RHEL:
Red Hat Enterprise Linux Server release 8.4 (Ootpa)
Method 2: Use hostnamectl Command
The hostnamectl command displays comprehensive system information including hostname, kernel version, architecture, and operating system version. This command is available on systemd-based systems (RHEL 7+ and CentOS 7+).
hostnamectl
Example output:
Static hostname: myserver.example.com
Icon name: computer-server
Chassis: server
Machine ID: 123456789abcdef123456789abcdef12
Boot ID: fedcba9876543210fedcba9876543210
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1160.45.1.el7.x86_64
The Operating System line shows your CentOS or RHEL version clearly.
Method 3: Use lsb_release Command
The lsb_release command displays Linux Standard Base (LSB) information including distributor ID, release number, and description. Note that this command may require installing the redhat-lsb-core package first.
lsb_release -a
Example output for CentOS:
LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.9.2009 (Core) Release: 7.9.2009 Codename: Core
If lsb_release is not installed, install it with:
yum install redhat-lsb-core
Method 4: Use rpm Command
The rpm command can query the release package to determine your system version. This method works by checking the installed release package.
For CentOS:
rpm -q centos-release
For RHEL:
rpm -q redhat-release
Example output for CentOS:
centos-release-7-9.2009.1.el7.centos.x86_64
Example output for RHEL:
redhat-release-server-8.4-1.el8.x86_64
Comparison of Methods
| Method | Availability | Information Level | Best For |
|---|---|---|---|
| /etc/redhat-release | All versions | Basic version info | Quick version check |
| hostnamectl | RHEL/CentOS 7+ | Comprehensive system info | Detailed system overview |
| lsb_release | When LSB package installed | LSB-compliant details | Standard compliance info |
| rpm -q | All versions | Package-level details | Package management context |
Additional Tips
You can also use these alternative methods:
Kernel version: Use
uname -rto check the kernel version, which can indicate your OS versionOS information: Use
cat /etc/os-releasefor detailed OS information on newer systemsSystem information: Use
cat /proc/versionfor comprehensive system and kernel details
Conclusion
These four methods provide reliable ways to check your CentOS or RHEL version. The /etc/redhat-release file method is the quickest, while hostnamectl provides the most comprehensive system information. Choose the method that best fits your needs and system configuration.
