Guides

How to check your Linux version: Ubuntu, Debian, Rocky and the kernel

cat /etc/os-release shows the distribution and release on any modern Linux, uname -r the kernel. Plus lsb_release, hostnamectl and the codenames apt needs.

Published ~7 min read

Short answer: cat /etc/os-release shows the distribution and its version on Ubuntu, Debian, Rocky Linux, CentOS Stream, Alpine and practically every other current distribution. uname -r shows the kernel version. Those two commands answer almost every “which Linux am I on?” question.

any modern distribution
cat /etc/os-release     # distribution, version, codename
uname -r                # running kernel, e.g. 6.8.0-85-generic

The rest of this guide covers what each field means, distribution-specific files with more detail, how to tell a VM from a container, and why the codename matters when you add a repository.

What does /etc/os-release tell me?

On Ubuntu 24.04 it looks like this:

cat /etc/os-release · Ubuntu 24.04
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
...
UBUNTU_CODENAME=noble
  • PRETTY_NAME is the human-readable name, including the point release (24.04.3).
  • VERSION_ID is the release number scripts should compare (24.04, 12, 9.4).
  • VERSION_CODENAME is the codename package repositories use (noble, bookworm). The RHEL family leaves it out.
  • ID and ID_LIKE name the distribution and its family. Rocky Linux, for example, has ID="rocky" and ID_LIKE="rhel centos fedora".

The file is designed to be read by the shell, so scripts can source it. Do that in a subshell, so variables like NAME and VERSION do not leak into your script:

in a script
( . /etc/os-release && echo "$ID $VERSION_ID $VERSION_CODENAME" )
# ubuntu 24.04 noble

codename=$(. /etc/os-release && echo "$VERSION_CODENAME")

How do I check the Ubuntu version?

Besides /etc/os-release, Ubuntu has two classic answers. lsb_release is part of a standard Ubuntu install. On a minimal Debian it is missing, and sudo apt install lsb-release adds it.

Ubuntu
lsb_release -a
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description:    Ubuntu 24.04.3 LTS
# Release:        24.04
# Codename:       noble

lsb_release -cs        # just the codename: noble
cat /etc/lsb-release   # the same information as a file

Ubuntu also has an /etc/debian_version file, but on Ubuntu it names the Debian development branch the release was based on, such as trixie/sid on 24.04, not the Ubuntu version. Ignore it there.

How do I check the exact Debian point release?

/etc/os-release on Debian only says VERSION_ID="12". The point release, which changes every few months as fixes are rolled up, is in /etc/debian_version:

Debian
cat /etc/debian_version     # e.g. 12.12 or 13.1
cat /etc/os-release         # PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"

Codenames you will meet on servers today:

  • Debian: 11 bullseye, 12 bookworm, 13 trixie
  • Ubuntu: 20.04 focal, 22.04 jammy, 24.04 noble

How do I check Rocky Linux or CentOS Stream?

Rocky Linux · CentOS Stream
cat /etc/redhat-release     # Rocky Linux release 9.4 (Blue Onyx)
cat /etc/rocky-release      # the same on Rocky
cat /etc/centos-release     # CentOS Stream release 9
cat /etc/os-release         # VERSION_ID="9.4"

On Rocky Linux, the point release moves with updates: a server installed as 9.4 reports the current 9.x release after sudo dnf upgrade. CentOS Stream has no point releases at all. It is a continuously updated stream, so you will only ever see 9 or 8. lsb_release is not part of a standard Rocky 9 install, and you do not need it: /etc/os-release has the same information.

What does hostnamectl show?

hostnamectl summarises the system in one command: operating system, kernel, architecture and, on a virtual machine, the hypervisor.

hostnamectl · a KVM VPS (shortened)
 Static hostname: web-01
         Chassis: vm
  Virtualization: kvm
Operating System: Ubuntu 24.04.3 LTS
          Kernel: Linux 6.8.0-85-generic
    Architecture: x86-64
 Hardware Vendor: QEMU

systemd-detect-virt prints only the virtualisation type: kvm on a KVM virtual machine, lxc, openvz or docker inside a container, and none on bare metal. The difference matters more than it looks, as KVM vs OpenVZ explains: in a container you cannot choose your own kernel.

What is the difference between the kernel and the distribution version?

The distribution version (Ubuntu 24.04, Debian 12) describes the whole set of packages. The kernel is one of those packages, with its own version number, and it is updated separately over the life of a release:

uname
uname -r      # 6.8.0-85-generic             Ubuntu 24.04
              # 6.1.0-41-amd64               Debian 12
              # 5.14.0-427.13.1.el9_4.x86_64  Rocky Linux 9.4
uname -a      # kernel, hostname, build date and architecture in one line

Two things to know:

  • uname -r shows the running kernel. After a kernel update, the new one is installed but only runs after a reboot. Compare it with ls /boot/vmlinuz-*. Ubuntu also creates /var/run/reboot-required when a reboot is due, and on Rocky, dnf needs-restarting -r tells you.
  • In a container, the kernel is the host’s. uname -r inside an LXC, OpenVZ or Docker container shows the host kernel, which can look odd next to the distribution inside it. On a KVM VPS the kernel is your own.

Is my system 32-bit or 64-bit?

architecture
uname -m                    # x86_64 = 64-bit Intel/AMD, aarch64 = 64-bit ARM
dpkg --print-architecture   # Debian/Ubuntu package architecture: amd64, arm64
getconf LONG_BIT            # 64

On a current server the answer is almost always x86_64 or aarch64. The package architecture matters when you download a .deb or binary by hand: amd64 builds do not run on arm64.

Is my release still supported?

Check the vendor’s own pages, because dates shift and extended support offers change the picture: ubuntu.com/about/release-cycle for Ubuntu and debian.org/releases plus wiki.debian.org/LTS for Debian. A few points worth knowing:

  • Ubuntu 20.04 reached the end of standard support in May 2025. Security updates continue only through Ubuntu Pro (ESM).
  • CentOS Stream 8 reached end of life on 31 May 2024 and gets no updates.
  • Debian 11 was scheduled to leave its LTS period at the end of August 2026. Check the LTS page for its current status, and plan the move to 12 or 13. Upgrading in place is covered in upgrading Debian 12 to 13.

An unsupported release still boots and runs. It just stops getting security fixes, and eventually its package mirrors move to an archive, which breaks apt update.

Why does the codename matter?

Package repositories are organised by codename, not by version number. Every APT source names one, and third-party repositories (Docker, PostgreSQL, Node.js and the rest) ask you to fill in yours:

codename in an APT source
deb http://deb.debian.org/debian bookworm main

# third-party repositories usually take it from os-release:
echo "deb https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable"

A repository line with the wrong codename is a classic cause of Unable to locate package and dependency errors. PPAs are built per Ubuntu codename, which is one reason a PPA added on Debian breaks; see add-apt-repository: command not found. On Rocky and CentOS Stream, repositories are keyed by the major version instead (el9), and the package manager is dnf; see yum: command not found.

How do I check the version on Windows Server?

Windows Server
winver                                                  # dialog with version and build
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"    # command prompt
Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber   # PowerShell

Build 20348 is Windows Server 2022, and build 17763 is Windows Server 2019. If the name ends in Evaluation, the server runs the time-limited evaluation licence, explained in the evaluation licence guide.

Frequently asked

/etc/os-release is missing. How do I find the version?

Try 'cat /usr/lib/os-release', which is the file /etc/os-release usually links to, and then 'cat /etc/issue', which most distributions fill with their name and version. Distribution files such as /etc/debian_version, /etc/redhat-release or /etc/alpine-release also work. If none of them exist, you are on a very old system or in a stripped-down container image.

What does LTS mean in Ubuntu?

Long Term Support. Ubuntu publishes an LTS release every two years in April, such as 20.04, 22.04 and 24.04, and gives it five years of standard security updates, with longer coverage available through Ubuntu Pro. Interim releases in between get only nine months, so servers should run an LTS release.

How do I know whether I am in a container or a virtual machine?

Run 'systemd-detect-virt'. It prints kvm or another hypervisor name on a virtual machine; lxc, openvz or docker inside a container; and none on bare metal. 'hostnamectl' shows the same thing in its Virtualization line. In a container, 'uname -r' shows the host's kernel, not one of your own.

How do I check the version on Windows Server?

Run 'winver' for a dialog, or 'systeminfo | findstr /B /C:"OS Name" /C:"OS Version"' in a command prompt. Build 20348 is Windows Server 2022 and build 17763 is Windows Server 2019. An edition name ending in Evaluation means the server runs on the time-limited evaluation licence.

Related articles

All guides