Skip to main content
Blog|
How-to guides

How to check your Ubuntu version

|
Mar 30, 2026|8 min read
HOW-TO GUIDESHow to check your UbuntuversionHOSTNEYhostney.comMarch 30, 2026

Knowing which Ubuntu version you are running matters for package compatibility, security updates, PHP and MySQL version availability, and end-of-life planning. Different Ubuntu releases ship with different default software versions, and instructions that work on Ubuntu 22.04 may not work on 24.04. Before installing software, following a tutorial, or troubleshooting an issue, verify your version first.

This guide covers every method for checking your Ubuntu version from the command line, what the version numbers mean, how to check the kernel version separately, and how this applies to other Linux distributions.

lsb_release -a#

The most straightforward method:

lsb_release -a

Output:

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

This tells you everything: the distribution name, the full version with point release, whether it is LTS, and the codename. The codename ( noble , jammy , focal ) is used in package repository URLs and is often referenced in installation instructions.

If you only need the version number:

lsb_release -r
Release:        24.04

Or just the codename:

lsb_release -c
Codename:       noble

On minimal server installations, lsb_release may not be installed. If you get “command not found”:

sudo apt install lsb-release

Or use one of the alternative methods below that do not require installing anything.

cat /etc/os-release#

This file exists on every modern Linux distribution and does not require any additional packages:

cat /etc/os-release

Output:

PRETTY_NAME="Ubuntu 24.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.1 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble

This is the most reliable method because the file is always present. You can extract specific fields:

# Just the version number
grep VERSION_ID /etc/os-release
VERSION_ID="24.04"
# Just the pretty name
grep PRETTY_NAME /etc/os-release
PRETTY_NAME="Ubuntu 24.04.1 LTS"

In scripts, you can source the file to get variables directly:

. /etc/os-release
echo $VERSION_ID
echo $VERSION_CODENAME

This is the approach used in many installation scripts that need to adapt their behavior based on the OS version.

hostnamectl#

hostnamectl

Output:

 Static hostname: web-server-01
       Icon name: computer-vm
         Chassis: vm
      Machine ID: a1b2c3d4e5f6...
         Boot ID: f6e5d4c3b2a1...
  Virtualization: kvm
Operating System: Ubuntu 24.04.1 LTS
          Kernel: Linux 6.8.0-45-generic
    Architecture: x86-64

hostnamectl shows the OS version alongside other useful system information: hostname, whether it is a VM, the kernel version, and the architecture. This is a good single command when you need a quick overview of the system.

uname -a#

uname -a

Output:

Linux web-server-01 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux

uname shows the kernel version, not the Ubuntu version. The kernel version (6.8.0-45) and the Ubuntu version (24.04) are different things. Ubuntu 24.04 ships with kernel 6.8, but Ubuntu 22.04 ships with kernel 5.15. The kernel can also be updated independently of the OS version through HWE (Hardware Enablement) kernels.

Use uname when you specifically need the kernel version, for example when checking driver compatibility or kernel module requirements. For the Ubuntu version, use lsb_release or /etc/os-release .

Kernel version only

uname -r
6.8.0-45-generic

The -r flag returns just the kernel release string. This is the value you need when checking kernel-specific compatibility.

cat /etc/issue#

cat /etc/issue
Ubuntu 24.04.1 LTS \n \l

This file contains the pre-login banner text. It shows the version but the \n and \l are escape codes for the hostname and terminal, which are replaced when displayed at a login prompt. It works for a quick check but /etc/os-release is more precise.

What Ubuntu version numbers mean#

Ubuntu uses a year.month versioning scheme. Ubuntu 24.04 was released in April 2024. Ubuntu 22.04 was released in April 2022. The first number is the year, the second is the month.

LTS vs non-LTS

LTS (Long Term Support) releases come out every two years in April (xx.04). They receive security updates for 5 years (10 years with Ubuntu Pro). LTS releases are what you run on servers. Current LTS releases:

VersionCodenameReleasedStandard support untilExtended (Pro) until
24.04Noble NumbatApril 2024April 2029April 2034
22.04Jammy JellyfishApril 2022April 2027April 2032
20.04Focal FossaApril 2020April 2025April 2030

Non-LTS (interim) releases come out every six months (xx.10 in October). They receive security updates for only 9 months. These are meant for desktops and development, not production servers. If you find a server running a non-LTS release like 23.10, it should be upgraded to an LTS release.

Point releases

Ubuntu 24.04.1 means the first point release of 24.04. Point releases bundle all security and bug fix updates released since the initial release into a single updated installation image. If you installed 24.04 at launch and kept it updated, your system is identical to a fresh 24.04.1 install. Point releases do not change the base version.

Why the version matters for hosting#

Different Ubuntu versions ship with different default software versions, and the package repositories contain different versions of key software:

SoftwareUbuntu 20.04Ubuntu 22.04Ubuntu 24.04
PHP (default)7.48.18.3
MySQL8.08.08.0
Nginx1.181.181.24
OpenSSL1.1.13.03.0
Python3.83.103.12

When following installation guides for PHP or MySQL, the commands and package names may differ between Ubuntu versions. A guide written for Ubuntu 22.04 might reference php8.1-fpm while your Ubuntu 24.04 system has php8.3-fpm as the default. Always check your version first.

The OpenSSL version difference between 20.04 and 22.04 is particularly important. OpenSSL 3.0 (Ubuntu 22.04+) dropped support for some legacy algorithms and changed default behavior for TLS connections. Applications that worked on 20.04 may need configuration changes on 22.04 if they rely on older cipher suites or certificate formats.

End of life and upgrade planning#

Running an Ubuntu version past its end-of-life date means you stop receiving security patches. Vulnerabilities discovered after EOL are not fixed. This is a significant risk for any internet-facing server.

Check your version’s support status:

ubuntu-support-status --show-unsupported 2>/dev/null || hwe-support-status --verbose 2>/dev/null

If this command is not available, compare your version against the table in the LTS section above.

Upgrading between LTS versions

Ubuntu supports direct upgrade between adjacent LTS releases:

sudo do-release-upgrade

This upgrades from one LTS to the next (20.04 to 22.04, or 22.04 to 24.04). You cannot skip an LTS version. To go from 20.04 to 24.04, you must upgrade to 22.04 first, then to 24.04.

Before upgrading a production server:

  • Back up everything. Database dumps, file backups, configuration files.
  • Test the upgrade on a staging server or VM first.
  • Review which package versions will change. PHP, MySQL, OpenSSL, and Nginx versions may all change during an LTS upgrade.
  • Schedule downtime. The upgrade process restarts services and may take 15-30 minutes.
  • Have console access available. If the upgrade breaks SSH, you need an alternative way to access the server.

On managed hosting, the hosting provider handles OS upgrades. On Hostney, servers are migrated to new OS versions without customer intervention. You do not need to run do-release-upgrade on a Hostney server.

Check if a reboot is required

After applying updates, Ubuntu sometimes requires a reboot for kernel or library changes to take effect:

cat /var/run/reboot-required 2>/dev/null && echo "Reboot required" || echo "No reboot needed"

If a reboot is needed, the file /var/run/reboot-required exists. The file /var/run/reboot-required.pkgs lists which packages triggered the reboot requirement.

Checking on other Linux distributions#

The methods above are Ubuntu-specific in their output but the underlying commands work across distributions.

Rocky Linux / CentOS / RHEL

cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
VERSION_ID="9.3"

Or the Red Hat-specific file:

cat /etc/redhat-release
Rocky Linux release 9.3 (Blue Onyx)

Hostney’s production servers run Rocky Linux 9 and Rocky Linux 10, not Ubuntu. If you are SSH’d into a Hostney server and check the version, you will see Rocky Linux. The commands in this guide still work because /etc/os-release and hostnamectl are standard across all modern Linux distributions.

Debian

cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"

Debian and Ubuntu share the same package management system (apt) and many of the same commands. Ubuntu is based on Debian, so many instructions written for one work on the other, but the default package versions differ.

Any distribution

/etc/os-release works on Ubuntu, Debian, Rocky Linux, CentOS, RHEL, Fedora, Arch, SUSE, and every other modern distribution. It is the universal method. If you are not sure what distribution a server is running, start there.

Using version checks in scripts#

If you are writing a script that needs to behave differently on different Ubuntu versions:

#!/bin/bash
. /etc/os-release

if [[ "$ID" != "ubuntu" ]]; then
    echo "This script is for Ubuntu only"
    exit 1
fi

case "$VERSION_ID" in
    "24.04")
        PHP_VERSION="8.3"
        ;;
    "22.04")
        PHP_VERSION="8.1"
        ;;
    "20.04")
        PHP_VERSION="7.4"
        ;;
    *)
        echo "Unsupported Ubuntu version: $VERSION_ID"
        exit 1
        ;;
esac

echo "Installing PHP $PHP_VERSION for Ubuntu $VERSION_ID"
sudo apt install php${PHP_VERSION}-fpm

This pattern is common in deployment scripts and configuration management tools. Sourcing /etc/os-release gives you reliable variables without parsing command output.

Quick reference#

# Full Ubuntu version info
lsb_release -a

# Version number only
lsb_release -r

# From file (always available, no install needed)
cat /etc/os-release

# Extract version number from file
grep VERSION_ID /etc/os-release

# System overview including OS version
hostnamectl

# Kernel version (not Ubuntu version)
uname -r

# Pre-login banner (quick check)
cat /etc/issue

# Check if reboot is needed after updates
cat /var/run/reboot-required 2>/dev/null

# Works on any Linux distribution
cat /etc/os-release
CommandWhat it shows
lsb_release -a Full Ubuntu version, codename, description
cat /etc/os-release OS details in key=value format (universal)
hostnamectl OS version + hostname, kernel, architecture
uname -r Kernel version only (not OS version)
cat /etc/issue Pre-login banner with version