The fastest way to check the CentOS version is to read /etc/os-release. It exists on every CentOS, CentOS Stream, Rocky Linux, AlmaLinux and RHEL release, needs no extra packages and works for any user:
shell
1cat /etc/os-releaseOn CentOS Linux 7 the first lines look like this:
shell
1NAME="CentOS Linux"2VERSION="7 (Core)"3ID="centos"4ID_LIKE="rhel fedora"5VERSION_ID="7"6PRETTY_NAME="CentOS Linux 7 (Core)"If you want the full release number, such as 7.9, read /etc/centos-release instead:
shell
1cat /etc/centos-releaseshell
1CentOS Linux release 7.9.2009 (Core)If either file says "CentOS Linux", the release is end-of-life. CentOS Linux 7 stopped getting updates on June 30, 2024, and CentOS Linux 8 on December 31, 2021. The support table and migration options are further down.
All commands and outputs in this guide were tested in containers with CentOS Linux 7 and 8, CentOS Stream 8, 9 and 10, Rocky Linux 9 and 10, AlmaLinux 9 and 10, and RHEL 9 and 10 (UBI images).
All the ways to check the CentOS version
Run these commands in the server's terminal, locally or over SSH. None of them change anything on the system, and only hostnamectl and installing lsb_release need anything beyond a plain shell.
Read /etc/centos-release, /etc/redhat-release or /etc/system-release
These three files hold the same one-line release string. On CentOS, /etc/redhat-release and /etc/system-release point to /etc/centos-release:
shell
1cat /etc/centos-release2cat /etc/redhat-release3cat /etc/system-releaseWhat you get on each CentOS release:
shell
1CentOS Linux release 7.9.2009 (Core)2CentOS Linux release 8.4.21053CentOS Stream release 84CentOS Stream release 95CentOS Stream release 10 (Coughlan)/etc/centos-release only exists on CentOS. On Rocky Linux, AlmaLinux and RHEL use /etc/redhat-release or /etc/system-release, which exist on every distribution in this family.
Read /etc/os-release
/etc/os-release is the standard file that systemd-based distributions use to describe themselves. It's the best choice for scripts, because the fields have fixed names. Full output on CentOS Linux 7:
shell
1NAME="CentOS Linux"2VERSION="7 (Core)"3ID="centos"4ID_LIKE="rhel fedora"5VERSION_ID="7"6PRETTY_NAME="CentOS Linux 7 (Core)"7ANSI_COLOR="0;31"8CPE_NAME="cpe:/o:centos:centos:7"9HOME_URL="https://www.centos.org/"10BUG_REPORT_URL="https://bugs.centos.org/"11
12CENTOS_MANTISBT_PROJECT="CentOS-7"13CENTOS_MANTISBT_PROJECT_VERSION="7"14REDHAT_SUPPORT_PRODUCT="centos"15REDHAT_SUPPORT_PRODUCT_VERSION="7"And on CentOS Stream 9:
shell
1NAME="CentOS Stream"2VERSION="9"3ID="centos"4ID_LIKE="rhel fedora"5VERSION_ID="9"6PLATFORM_ID="platform:el9"7PRETTY_NAME="CentOS Stream 9"8ANSI_COLOR="0;31"9LOGO="fedora-logo-icon"10CPE_NAME="cpe:/o:centos:centos:9"11HOME_URL="https://centos.org/"12BUG_REPORT_URL="https://issues.redhat.com/"13REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 9"14REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"Note that ID is centos on both. Use NAME to tell CentOS Linux from CentOS Stream. In a shell script, source the file and print the fields you need:
shell
1. /etc/os-release && echo "$NAME $VERSION_ID"shell
1CentOS Linux 7The same line prints CentOS Stream 9, Rocky Linux 9.8 or AlmaLinux 9.8 on those systems.
Use hostnamectl
hostnamectl shows the operating system, kernel and architecture in one view:
shell
1hostnamectlOutput on CentOS Stream 9 (machine and boot IDs removed):
shell
1 Static hostname: web012 Virtualization: docker3Operating System: CentOS Stream 94 CPE OS Name: cpe:/o:centos:centos:95 Kernel: Linux 6.12.76-linuxkit6 Architecture: arm64On AlmaLinux 10 and other recent releases it also prints OS Support End, which tells you right away how long the release gets updates.
hostnamectl talks to systemd, so it only works on a host or VM that booted with systemd. Inside a regular container it fails with System has not been booted with systemd as init system (PID 1). Can't operate. Minimal images such as the CentOS Stream and Rocky Linux containers don't include it at all.
Query the release package with rpm
Every release in this family installs one package that owns the release files. This command finds it without you having to know its name:
shell
1rpm -qf /etc/redhat-releaseshell
1centos-release-7-9.2009.0.el7.centos.x86_64The package name changes between releases, which is why rpm -q centos-release, the command many guides suggest, returns package centos-release is not installed on anything newer than CentOS 7:
Release | Release package |
|---|---|
CentOS Linux 7 |
|
CentOS Linux 8 |
|
CentOS Stream 8, 9, 10 |
|
Rocky Linux |
|
AlmaLinux |
|
RHEL |
|
To get just the major version, for example in a script that picks the right repository, ask rpm for the rhel macro. It prints 7, 8, 9 or 10:
shell
1rpm -E %{rhel}Use lsb_release
lsb_release -a is the command people know from Ubuntu and Debian. On CentOS and its relatives it isn't installed by default, so you'll see lsb_release: command not found first.
On CentOS 7 it comes with the redhat-lsb-core package:
shell
1yum install -y redhat-lsb-core2lsb_release -ashell
1LSB Version: :core-4.1-amd64:core-4.1-noarch2Distributor ID: CentOS3Description: CentOS Linux release 7.9.2009 (Core)4Release: 7.9.20095Codename: CoreThe CentOS 7 mirrors are offline, so yum install only works if the repositories already point to the CentOS vault archive. That's one more reason to use /etc/os-release instead.
On CentOS Stream 9 and 10, Rocky Linux and AlmaLinux 9 and 10, redhat-lsb is gone. A small lsb_release package is available from EPEL:
shell
1dnf install -y epel-release2dnf install -y lsb_release3lsb_release -ashell
1LSB Version: n/a2Distributor ID: CentOS3Description: CentOS Stream 94Release: 95Codename: n/aOn RHEL, epel-release isn't in the Red Hat repositories. Install it from the Fedora project as described in the EPEL getting started guide:
shell
1dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpmHow to read the CentOS version number
CentOS Linux release 7.9.2009 has three parts:
- 7 is the major version. It defines the package base and the support date.
- 9 is the minor version, the point release. CentOS Linux 7.9 was the last one for CentOS 7.
- 2009 is the date of the upstream RHEL source the release was built from, in YYMM format: September 2020.
CentOS Linux 8 used the same scheme, for example 8.4.2105. CentOS Stream has no minor versions at all: it reports only 9 or 10, because it's a continuously updated stream, not a series of point releases. Rocky Linux and AlmaLinux use major and minor numbers, like 9.8.
How to check the kernel version
The distribution version and the kernel version are different things. To see the running kernel, use uname -r:
shell
1uname -rOn a CentOS 7 server with the last kernel update installed, it prints:
shell
13.10.0-1160.119.1.el7.x86_64The parts of this string:
3.10.0is the upstream Linux kernel version (version, patch level, sublevel). Red Hat keeps this number for the whole life of a major release: every CentOS 7 kernel is 3.10.0, every EL9 kernel is 5.14.0, every EL10 kernel is 6.12.0.1160.119.1is the Red Hat build and errata number. This is the part that grows with each kernel update.el7means Enterprise Linux 7. On Rocky Linux 9.8 you'll see something like5.14.0-687.64.1.el9_8, whereel9_8points to the 9.8 point release.x86_64is the architecture. On ARM servers it'saarch64.
Inside a container, uname -r shows the host's kernel, not one from the image. A CentOS container on Docker Desktop reports something like 6.12.76-linuxkit. Check the kernel on the host or VM itself.
uname has a few other useful flags:
uname -aprints everything at once.uname -sprints the kernel name (Linux).uname -nprints the hostname.uname -vprints the kernel build date.uname -mprints the machine architecture.uname -oprints the operating system (GNU/Linux).
How to tell CentOS Linux from CentOS Stream
Since 2021 "CentOS" can mean two different things, and they have different support dates:
- CentOS Linux 7 and 8 were rebuilds of RHEL. Both are end-of-life.
- CentOS Stream 8, 9 and 10 are the development branch that sits just ahead of the next RHEL minor release. Stream 8 is end-of-life, Stream 9 and 10 still get updates.
Three quick ways to see which one you have:
/etc/centos-releasesaysCentOS Linux release ...orCentOS Stream release ....NAMEin/etc/os-releaseis"CentOS Linux"or"CentOS Stream".IDiscentoson both, so don't rely on it.rpm -qf /etc/redhat-releasereturnscentos-releaseorcentos-linux-releaseon CentOS Linux, andcentos-stream-releaseon Stream.
A CentOS Linux 8 server that was switched to Stream 8 reports CentOS Stream release 8. It's still end-of-life.
The same commands on Rocky Linux, AlmaLinux and RHEL
Rocky Linux, AlmaLinux and RHEL use the same files, so everything above works there too, except /etc/centos-release, which doesn't exist. Each distribution also has its own release file:
shell
1cat /etc/rocky-release2cat /etc/almalinux-release3cat /etc/redhat-releaseWhat cat /etc/redhat-release prints on current releases:
shell
1Rocky Linux release 9.8 (Blue Onyx)2Rocky Linux release 10.2 (Red Quartz)3AlmaLinux release 9.8 (Olive Jaguar)4AlmaLinux release 10.2 (Lavender Lion)5Red Hat Enterprise Linux release 9.8 (Plow)6Red Hat Enterprise Linux release 10.2 (Coughlan)In /etc/os-release, the ID field is rocky, almalinux or rhel. Rocky Linux and AlmaLinux also add a SUPPORT_END field with the end-of-life date, for example on Rocky Linux 9 (trimmed):
shell
1NAME="Rocky Linux"2VERSION="9.8 (Blue Onyx)"3ID="rocky"4ID_LIKE="rhel centos fedora"5VERSION_ID="9.8"6PLATFORM_ID="platform:el9"7PRETTY_NAME="Rocky Linux 9.8 (Blue Onyx)"8SUPPORT_END="2032-05-31"To check support status in one line on any of them:
shell
1grep -E '^(PRETTY_NAME|SUPPORT_END)=' /etc/os-releaseIs your CentOS version still supported?
Release | End of updates | Status |
|---|---|---|
CentOS Linux 7 | June 30, 2024 | End-of-life |
CentOS Linux 8 | December 31, 2021 | End-of-life |
CentOS Stream 8 | May 31, 2024 | End-of-life |
CentOS Stream 9 | May 31, 2027 (expected) | Supported |
CentOS Stream 10 | May 31, 2030 (expected) | Supported |
The CentOS Linux 7 and Stream 8 dates come from the CentOS Project announcement. The CentOS Stream 9 and 10 dates are listed on the CentOS download page and match the end of full support for RHEL 9 and RHEL 10.
An end-of-life CentOS server gets no security fixes. The base repositories are archived, so yum update either fails or finds nothing new. If the server is exposed to the internet or handles customer data, plan a migration now.
Keep in mind that CentOS Stream isn't a drop-in replacement for CentOS Linux. It gets changes before RHEL does, and each Stream version is supported for about five years, half as long as a RHEL major release. For servers you want to install and leave alone, Rocky Linux, AlmaLinux or RHEL are closer to what CentOS Linux used to be. Rocky Linux and AlmaLinux 9 get updates until 2032, version 10 until 2035, as the SUPPORT_END field above shows.
Migration options if you still run CentOS Linux
There are three ways forward: convert the server in place, upgrade it in place to a newer major version, or buy extended support while you rebuild. The tools below were checked against their documentation, not run as part of this guide. Take a backup or snapshot and try the conversion on a copy of the server first.
CentOS 8 or Stream 8: convert in place
Both Rocky Linux and AlmaLinux ship a script that swaps the repositories and release packages for theirs without reinstalling the server.
migrate2rocky converts EL8 and EL9 systems (CentOS, CentOS Stream, AlmaLinux, RHEL, Oracle Linux) to Rocky Linux of the same major version. EL10 isn't supported yet:
shell
1curl -O https://raw.githubusercontent.com/rocky-linux/rocky-tools/main/migrate2rocky/migrate2rocky.sh2chmod u+x migrate2rocky.sh3./migrate2rocky.sh -ralmalinux-deploy does the same for AlmaLinux. It supports CentOS Linux 8.4 and later, CentOS Stream 8, 9 and 10, RHEL, Rocky Linux and Oracle Linux 8 to 10. Use -d when converting from CentOS Stream, because Stream packages can be newer than AlmaLinux ones and need a downgrade:
shell
1curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh2sudo bash almalinux-deploy.shBoth run as root. Neither supports CentOS 7.
CentOS 7: upgrade with ELevate or rebuild
A CentOS 7 server can't be converted straight to a supported release, because there is no supported 7.x rebuild left. You have two options.
Upgrade in place with ELevate. The AlmaLinux project's ELevate uses the Leapp tool to upgrade between major versions. From CentOS 7 it goes in stages: first to an EL8 distribution such as AlmaLinux 8 or Rocky Linux 8, then to EL9, then to EL10. Each stage is a full major upgrade with its own pre-checks, so expect to fix blockers along the way. The CentOS 7 repositories have to point to the vault archive before you start, as the ELevate quickstart guide explains.
Rebuild on a new server. For most production servers this is the safer path: install Rocky Linux, AlmaLinux or RHEL 9 or 10 on a new machine, move the application and data, then switch traffic. It takes more planning, but you get a clean system, you can test before cutting over, and the old server stays as a fallback.
Buy time with extended support
If you can't migrate yet, commercial extended support keeps security fixes coming for a while:
- RHEL 7 ELS. Red Hat sells Extended Life Cycle Support for RHEL 7 until May 31, 2029 (see the RHEL life cycle policy). A CentOS 7 server first has to be converted to RHEL 7 with Red Hat's Convert2RHEL tool.
- Third-party ELS for CentOS 7. Vendors such as TuxCare sell security updates for CentOS 7 itself, so the server stays on CentOS.
Extended support is a bridge, not a destination. It buys time to plan the migration without running an unpatched server in the meantime.
Wrapping up
To check the CentOS version, run cat /etc/os-release or cat /etc/centos-release. For the kernel, run uname -r. The same commands work on CentOS Stream, Rocky Linux, AlmaLinux and RHEL, with /etc/redhat-release in place of /etc/centos-release.
If the output says CentOS Linux 7 or 8, the server no longer gets security updates. Moving it to Rocky Linux, AlmaLinux or RHEL is a well-trodden path, but it still needs a backup, a test run and a rollback plan. If you'd rather hand that off, our engineers plan and run Linux and cloud migrations without downtime surprises.
