How to check CentOS version number you are using

Published Updated

10 min read

Find out which CentOS release a server runs with one command, read the version number correctly, and check the kernel. The guide covers every common method, shows how to tell CentOS Linux from CentOS Stream, works the same on Rocky Linux, AlmaLinux and RHEL, and explains what to do if the release is already end-of-life.


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-release

On 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-release

shell

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-release
2cat /etc/redhat-release
3cat /etc/system-release

What you get on each CentOS release:

shell

1CentOS Linux release 7.9.2009 (Core)
2CentOS Linux release 8.4.2105
3CentOS Stream release 8
4CentOS Stream release 9
5CentOS 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 7

The 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

1hostnamectl

Output on CentOS Stream 9 (machine and boot IDs removed):

shell

1 Static hostname: web01
2 Virtualization: docker
3Operating System: CentOS Stream 9
4 CPE OS Name: cpe:/o:centos:centos:9
5 Kernel: Linux 6.12.76-linuxkit
6 Architecture: arm64

On 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-release

shell

1centos-release-7-9.2009.0.el7.centos.x86_64

The 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-release

CentOS Linux 8

centos-linux-release

CentOS Stream 8, 9, 10

centos-stream-release

Rocky Linux

rocky-release

AlmaLinux

almalinux-release

RHEL

redhat-release

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-core
2lsb_release -a

shell

1LSB Version: :core-4.1-amd64:core-4.1-noarch
2Distributor ID: CentOS
3Description: CentOS Linux release 7.9.2009 (Core)
4Release: 7.9.2009
5Codename: Core

The 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-release
2dnf install -y lsb_release
3lsb_release -a

shell

1LSB Version: n/a
2Distributor ID: CentOS
3Description: CentOS Stream 9
4Release: 9
5Codename: n/a

On 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.rpm

How 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 -r

On a CentOS 7 server with the last kernel update installed, it prints:

shell

13.10.0-1160.119.1.el7.x86_64

The parts of this string:

  • 3.10.0 is 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.1 is the Red Hat build and errata number. This is the part that grows with each kernel update.
  • el7 means Enterprise Linux 7. On Rocky Linux 9.8 you'll see something like 5.14.0-687.64.1.el9_8, where el9_8 points to the 9.8 point release.
  • x86_64 is the architecture. On ARM servers it's aarch64.

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 -a prints everything at once.
  • uname -s prints the kernel name (Linux).
  • uname -n prints the hostname.
  • uname -v prints the kernel build date.
  • uname -m prints the machine architecture.
  • uname -o prints 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-release says CentOS Linux release ... or CentOS Stream release ....
  • NAME in /etc/os-release is "CentOS Linux" or "CentOS Stream". ID is centos on both, so don't rely on it.
  • rpm -qf /etc/redhat-release returns centos-release or centos-linux-release on CentOS Linux, and centos-stream-release on 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-release
2cat /etc/almalinux-release
3cat /etc/redhat-release

What 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-release

Is 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.sh
2chmod u+x migrate2rocky.sh
3./migrate2rocky.sh -r

almalinux-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.sh
2sudo bash almalinux-deploy.sh

Both 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.

Alex Kondratiev

Alex Kondratiev

Co-founder and CEO of ITsyndicate. DevOps engineer with 15+ years in cloud infrastructure, Infrastructure as Code, Kubernetes and automation, focused on secure, scalable and resilient systems.

More about Alex

Stay online.
Stay in command.