How to check your Ubuntu or Linux version

Find out which Ubuntu, Debian, AlmaLinux or Rocky Linux release a server runs, plus its kernel and architecture, with one or two commands.

5–8 minutes
Laptop showing code next to a coffee mug

To check your Ubuntu version, run lsb_release -a or cat /etc/os-release in a terminal. This guide is for anyone who has just logged in to a server, or opened Linux on their own PC, and needs to know exactly what it is running before following instructions or installing software.

On Ubuntu, run **lsb_release -a** and read the Description line, for example Ubuntu 24.04.1 LTS. On any modern Linux system, including Debian, AlmaLinux and Rocky Linux, run **cat /etc/os-release** and read PRETTY_NAME. For the kernel version, run **uname -r. On servers with systemd, hostnamectl** shows the operating system, kernel and architecture together.

Why the version matters

Linux is not one product. Ubuntu, Debian, AlmaLinux and Rocky Linux are different distributions (often shortened to distros): each one packages the Linux kernel with its own tools, package manager and release schedule. A command that works on Ubuntu may not exist on AlmaLinux, and a guide written for Ubuntu 20.04 may give the wrong file paths on 24.04.

Knowing the exact version tells you:

  • Which instructions to follow. Ubuntu and Debian use apt; AlmaLinux and Rocky Linux use dnf.
  • Which software versions you will get. Each release ships its own default PHP, NginxNginx A fast, popular program that sends web pages to visitors and can pass requests on to apps behind it. More about Nginx → and MariaDB versions.
  • Whether the system still gets security fixes. Every release has an end of support date. After it, no more patches arrive, even if you have automatic security updates turned on.

You need a terminal for every method below. On a remote server, that means connecting with SSH first. If you want somewhere safe to practise, WSL gives you an Ubuntu terminal on a Windows PC.

Check the Ubuntu version

1. Run lsb_release

lsb_release -a

On an Ubuntu 24.04 server you will see something like this:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble

The No LSB modules are available. line is normal and harmless. What each line means:

LineMeaning
Distributor IDThe distribution name
DescriptionThe full name, including the point release (the .1 in 24.04.1)
ReleaseThe version number. Ubuntu versions are the year and month of release, so 24.04 came out in April 2024
CodenameThe release nickname. Software repositories and some guides use this instead of the number

If you only want the number, add -r and -s (short):

lsb_release -rs

This prints just 24.04, which is handy in scripts.

2. Check whether it is an LTS release

LTS means Long Term Support. Ubuntu LTS releases come out every two years in April of even years (20.04, 22.04, 24.04) and get five years of standard security updates. Releases in between, such as 24.10, are supported for only nine months. For a server, you almost always want an LTS release. If the Description line does not say LTS, plan to move to one.

Common codenames you will meet on servers:

VersionCodename
Ubuntu 20.04 LTSfocal
Ubuntu 22.04 LTSjammy
Ubuntu 24.04 LTSnoble

Ubuntu publishes the support dates for every release on its release cycle page, linked under Official documentation below.

Check the version on any Linux distribution

Read /etc/os-release

Almost every current distribution has a small text file called /etc/os-release that describes the system. It is the most reliable method because it does not depend on any extra package being installed.

cat /etc/os-release

On a Rocky Linux 9 server the output starts like this:

NAME="Rocky Linux"
VERSION="9.4 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"

The useful fields:

  • PRETTY_NAME is the human-readable name and version.
  • ID is the short name of the distribution (ubuntu, debian, almalinux, rocky).
  • VERSION_ID is the version number on its own.
  • ID_LIKE names the family it belongs to. rhel means instructions written for Red Hat Enterprise Linux will usually work; debian means Debian-style instructions apply.

To print just one line, use grep:

grep PRETTY_NAME /etc/os-release

Use hostnamectl

On systems that use systemd (all the distributions named in this guide), hostnamectl gives a tidy summary:

hostnamectl

Look for these lines in the output:

Operating System: Debian GNU/Linux 12 (bookworm)
          Kernel: Linux 6.1.0-25-amd64
    Architecture: x86-64

This is often the quickest way to see the operating system, kernel and architecture at once. Inside some containers, hostnamectl cannot reach systemd and prints an error instead; use /etc/os-release there.

Distribution-specific files

Older guides often mention these files. They still exist and can give a more precise number:

FileFound onExample content
/etc/debian_versionDebian and Ubuntu12.7 on Debian. On Ubuntu it shows the Debian base, such as trixie/sid, not the Ubuntu version
/etc/redhat-releaseAlmaLinux, Rocky Linux, RHEL, CentOSAlmaLinux release 9.4 (Seafoam Ocelot)

Read either with cat, for example cat /etc/redhat-release. Because /etc/debian_version can mislead on Ubuntu, prefer /etc/os-release there.

Check the kernel version and architecture

The kernel is the core of the operating system that talks to the hardware. Its version is separate from the distribution version: Ubuntu 24.04, for example, can run several different kernel versions over its life as updates arrive. You need the kernel version when a vendor’s driver or monitoring agent lists kernel requirements, or when checking that a kernel update has taken effect after a reboot.

uname -r

This prints something like 6.8.0-45-generic. For everything uname knows, including the host name and architecture, use:

uname -a

The architecture is the type of processor the system is built for. Downloads often come in separate builds, so check it before installing software by hand:

uname -m
OutputMeaningDownload to choose
x86_64Standard 64-bit Intel or AMDamd64 or x86_64
aarch6464-bit ARM, such as many cloud ARM servers and a Raspberry Pi with a 64-bit OSarm64 or aarch64

On Debian and Ubuntu, dpkg --print-architecture prints the name the package system uses (amd64 or arm64), which matches most download pages.

If you updated the kernel but uname -r still shows the old version, the server has not been rebooted yet. On Ubuntu and Debian, the file /var/run/reboot-required exists while a reboot is waiting.

Common problems

SymptomCauseFix
lsb_release: command not foundThe lsb-release package is not installed, which is common on minimal Debian, AlmaLinux and Rocky Linux imagesUse cat /etc/os-release instead. There is no need to install anything
hostnamectl prints System has not been booted with systemdYou are inside a container or an older WSL setup without systemdUse cat /etc/os-release
Version shows a non-LTS Ubuntu release such as 23.10The server was installed from or upgraded to an interim releaseCheck its support dates and plan an upgrade to the next LTS before support ends
Kernel version did not change after updatesThe new kernel is installed but not runningReboot at a quiet time, then run uname -r again
Output says CentOS Linux 7 or 8These releases have reached end of life and no longer get fixesPlan a move to a supported distribution such as AlmaLinux or Rocky Linux

Official documentation

Get the next guide

One email when there is something worth reading: new guides, errors going around, and hosting changes that affect your site.

No tracking pixels, and one click to leave.

Something out of date? Software changes. If a step no longer works, tell us and we will check it and update the page.