The Quick Answer
cat /etc/redhat-releaseThe output is one line with the distribution name, the word release, the version number, and a release name in parentheses. The file exists on Red Hat Enterprise Linux and on the compatible distributions AlmaLinux and Rocky Linux, so the same command answers the question on all three. No sudo is needed.
Each Distribution's Own File
| File | Present on |
|---|---|
/etc/ | All three |
/etc/ | AlmaLinux |
/etc/ | Rocky Linux |
/etc/ | All three |
On AlmaLinux and Rocky Linux, /etc/redhat-release and /etc/system-release are links to the distribution's own file, so they all print the same line. Check with ls -l /etc/*release.
/etc/os-release for Scripts
cat /etc/os-releaseThis file exists on every current Linux distribution. The lines that matter here:
- ID: the distribution, such as
rhel,almalinux, orrocky. - ID_
LIKE: related distributions; it names the RHEL family on AlmaLinux and Rocky Linux. - VERSION_
ID: the release number, such as 9.6. - PLATFORM_
ID: the major release in the formplatform:el9orplatform:el10. - PRETTY_
NAME: the full name for display.
In a shell script, load the file and use the values:
. /etc/os-release
echo "$ID ${VERSION_ID%%.*}"The %%.* part cuts everything after the first dot, which leaves the major release.
hostnamectl
hostnamectlThe Operating System line shows the full name and release, and the Kernel line the running kernel. It is a good summary when you also want the virtualization type and host name.
Ask the Package Database
rpm -q almalinux-release
rpm -q rocky-release
rpm -q redhat-releaseOnly the one that matches your system is installed; the others report that the package is not installed. The package version includes the release number. To print only the major release, ask rpm for the macro the distribution defines:
rpm -E %{rhel}It prints a single number, such as 9, and is handy in scripts that choose a repository by major release.
Major and Minor Releases
The number before the dot is the major release, such as 8, 9, or 10. Each major release has its own package base and is upgraded to the next only by a migration or a reinstall. The number after the dot is a minor release, such as 9.5 to 9.6. Minor releases arrive through normal updates:
sudo dnf upgradeAfter that, /etc/redhat-release shows the new minor release. Software built for a major release is meant to keep working across its minor releases.
Release Version vs Kernel Version
uname -r prints the kernel, not the distribution release. On these systems the kernel name contains el and the major release, such as el9, sometimes followed by a minor number. That is only a hint: the kernel can lag behind or run ahead of the installed release. Read the release from the files above and the kernel with uname; how to check the kernel version covers the kernel side, including the difference between the running kernel and the installed ones.
Which Distribution Is This?
If you do not know whether a server runs AlmaLinux or Rocky Linux, the ID line in /etc/os-release settles it. The two are built to be compatible with RHEL and with each other; the differences are in AlmaLinux vs Rocky Linux. On a Debian or Ubuntu server, none of the RHEL files exist; see how to check your Ubuntu version instead.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations