Red Hat Enterprise Linux uses specific version numbers to determine support lifecycles and available software packages. Knowing How To Check Os Version In Linux Redhat is essential for system administrators and developers who need to ensure compatibility with applications and security updates. This guide provides multiple methods to identify your Red Hat version quickly and accurately.
Whether you are managing a single server or a fleet of machines, understanding your OS version helps you plan upgrades and troubleshoot issues. The commands below work on Red Hat Enterprise Linux 6, 7, 8, and 9, as well as most derivatives like CentOS and Rocky Linux.
How To Check Os Version In Linux Redhat
The most straightforward way to check your Red Hat version is using the cat command on the /etc/redhat-release file. This file contains the exact release information set by Red Hat.
- Open a terminal window on your Red Hat system.
- Type the following command and press Enter:
cat /etc/redhat-release
You will see output similar to:
Red Hat Enterprise Linux Server release 7.9 (Maipo)
This method works on all Red Hat-based distributions and provides a human-readable string. The version number appears after “release” and before the codename in parentheses.
Using The Hostnamectl Command
The hostnamectl command displays system information including the operating system version. It is part of the systemd suite and works on Red Hat 7 and later.
hostnamectl
Output example:
Static hostname: server01.example.com
Icon name: computer-vm
Chassis: vm
Machine ID: abc123def456
Boot ID: ghi789jkl012
Virtualization: kvm
Operating System: Red Hat Enterprise Linux 8.4 (Ootpa)
CPE OS Name: cpe:/o:redhat:enterprise_linux:8.4:GA
Kernel: Linux 4.18.0-305.el8.x86_64
Architecture: x86-64
The “Operating System” line shows the full version string. This command also provides kernel and architecture details, making it a comprehensive tool for system checks.
Checking The /Etc/os-release File
Most modern Linux distributions include a standardized /etc/os-release file. Red Hat Enterprise Linux 7 and later use this file for machine-readable OS identification.
cat /etc/os-release
Sample output:
NAME="Red Hat Enterprise Linux"
VERSION="8.6 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.6"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.6 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.6:GA"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
The VERSION_ID field gives you the exact version number (e.g., 8.6). This format is ideal for scripting because it is consistent across distributions.
Using The Rpm Command
Red Hat Package Manager (RPM) stores package metadata. You can query the redhat-release package to get the version.
rpm -q redhat-release
Output:
redhat-release-8.6-1.0.el8.x86_64
The version number appears after the package name. In this example, 8.6 is the release version. This method is reliable because it queries the actual installed package.
Using The Neofetch Or Screenfetch Tools
If you prefer a visual display, tools like neofetch or screenfetch show system information in a colorful format. They are not installed by default but can be added via EPEL.
sudo yum install neofetch
neofetch
Output includes the OS logo and version information. This is useful for quick visual checks on desktop systems.
Checking The Kernel Version
While not the same as the OS version, the kernel version is often needed for compatibility checks. Use the uname command.
uname -r
Output example:
4.18.0-372.el8.x86_64
The kernel version includes the major.minor.patch numbers. The “el8” suffix indicates it is built for Enterprise Linux 8.
Using The Lsb_release Command
The Linux Standard Base (LSB) module provides version information. Install it if missing:
sudo yum install redhat-lsb-core
lsb_release -a
Output:
LSB Version: :core-4.1-noarch:core-4.1-x86_64
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 8.6 (Ootpa)
Release: 8.6
Codename: Ootpa
The “Release” line shows the version number. This method is standardized but requires an additional package installation.
Checking Version In Red Hat 6 And Older
For older Red Hat Enterprise Linux 6 systems, the /etc/redhat-release file still works. However, hostnamectl may not be available because systemd was introduced in RHEL 7.
cat /etc/redhat-release
Output for RHEL 6:
Red Hat Enterprise Linux Server release 6.10 (Santiago)
You can also check the /etc/issue file, but it may not be updated after system changes.
Using The Subscription Manager
If your system is registered with Red Hat Subscription Management, you can check version details via subscription-manager.
subscription-manager identity
Output includes system UUID and version information. This is useful for managed environments.
Automating Version Checks With Scripts
For system administrators managing multiple servers, scripting the version check saves time. Here is a simple bash script:
#!/bin/bash
# Check Red Hat version
if [ -f /etc/redhat-release ]; then
cat /etc/redhat-release
elif [ -f /etc/os-release ]; then
grep -i version_id /etc/os-release
else
echo "Cannot determine OS version"
fi
Save this as check_rhel_version.sh and run it on each server. You can extend it to output only the version number for parsing.
Using Ansible For Version Checks
Ansible can gather facts about managed nodes, including OS version. Use the setup module:
ansible all -m setup -a 'filter=ansible_distribution_version'
Output:
server01 | SUCCESS => {
"ansible_facts": {
"ansible_distribution_version": "8.6"
},
"changed": false
}
This method is ideal for large-scale environments where manual checks are impractical.
Common Issues When Checking Version
Sometimes the version information may be misleading. For example, after a minor update, the /etc/redhat-release file might not reflect the latest patch level. Always cross-check with rpm -q redhat-release for accuracy.
Another issue is when using containers or virtual machines. The host OS version may differ from the container’s version. Always check inside the container using the methods above.
Interpreting Version Numbers
Red Hat uses a three-part versioning scheme: major.minor.patch. For example, 8.6.0 means major version 8, minor version 6, and patch level 0. The minor version indicates the update stream.
- Major version: Significant architectural changes (e.g., RHEL 7 to 8)
- Minor version: Cumulative updates and new features
- Patch version: Security fixes and bug patches
Knowing the exact version helps you determine support status. Red Hat provides 10 years of support for each major version, with different phases.
Why Version Matters For Software Compatibility
Software packages often require specific Red Hat versions. For example, some applications only run on RHEL 8.4 or later. Checking the version before installation prevents compatibility issues.
Security advisories from Red Hat are version-specific. If you are running an unsupported version, you may miss critical patches. Regular version checks help maintain compliance.
Updating Your Red Hat System
Once you know your version, you can plan updates. Use yum update or dnf update to apply patches. Always check the release notes before major upgrades.
sudo dnf update
After updating, verify the version again to confirm the upgrade was successful.
Frequently Asked Questions
What is the difference between RHEL version and kernel version?
The RHEL version refers to the distribution release (e.g., 8.6), while the kernel version is the Linux kernel number (e.g., 4.18.0). They are related but not identical. Each RHEL release ships with a specific kernel version.
Can I check the OS version without root access?
Yes, all the commands mentioned (cat, hostnamectl, rpm) work without root privileges. The /etc/redhat-release file is readable by all users.
How do I check the version on a remote Red Hat server?
Use SSH to connect to the remote server and run the same commands. For example: ssh user@server cat /etc/redhat-release
What if /etc/redhat-release is missing?
On some minimal installations, this file may be absent. Use cat /etc/os-release or hostnamectl as alternatives. If both are missing, check rpm -q redhat-release.
Does the version check work on CentOS or Rocky Linux?
Yes, these distributions use similar files. CentOS shows “CentOS Linux release 8.5.2111” and Rocky Linux shows “Rocky Linux release 8.6 (Green Obsidian)”. The methods are identical.
Best Practices For Version Management
Document the OS version of each server in your inventory. Use configuration management tools like Ansible or Puppet to automate version tracking. Set up alerts when servers run outdated versions.
Regularly check for new minor releases. Red Hat releases minor updates approximately every 6 months. Staying current reduces security risks and ensures access to new features.
Using The Red Hat Customer Portal
The Red Hat Customer Portal provides version-specific documentation. Enter your version number to find relevant articles, knowledge base entries, and security advisories.
You can also check your subscription status on the portal. This helps verify that your system is entitled to updates.
Conclusion
Knowing How To Check Os Version In Linux Redhat is a fundamental skill for any Linux administrator. The methods covered here—from simple file checks to scripting and automation—give you flexibility for any scenario. Always verify your version before installing software or applying updates to maintain a stable and secure system.
Remember that the version number is just one piece of information. Combine it with kernel version, architecture, and subscription status for a complete picture of your system’s health. Regular checks help you stay on supported versions and avoid unexpected issues.