To check your Ubuntu version, open a terminal (Ctrl+Alt+T on desktop, or SSH into the server) and run lsb_release -a — or cat /etc/os-release, which works on every modern Linux distribution and inside containers. The rest of this guide covers what each command actually reports, which one to use in scripts, and the gotchas (containers, minimal images, uname) that make the obvious
answer wrong.
The fastest answer
If you just want the version and you're on Ubuntu (or any modern Debian-based system):
lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 26.04.1 LTS
Release: 26.04
Codename: resolute
That's the canonical answer. Description gives you the full name including the point release (Ubuntu 26.04.1 LTS), Release gives you the numeric version you'd write in a Dockerfile (26.04), and Codename gives you the adjective-animal name Ubuntu releases get (resolute, noble, jammy).
On Ubuntu 22.04 and older you'll also see a No LSB modules are available. line. It's harmless, and it no longer appears on Ubuntu 24.04 and newer.
Need just one value for a script? lsb_release -rs prints only the release (26.04) and lsb_release -cs only the codename (resolute).
If lsb_release: command not found, install the package — it isn't included in minimal installs or in the official ubuntu container images:
sudo apt-get install -y lsb-release
Which Ubuntu versions are current (November 2026)
Once you know your version, the next question is usually is it still supported?
As of November 2026, per Ubuntu's official list of releases:
| Version | Codename | Type | Latest point release | End of standard support |
|---|---|---|---|---|
| 26.10 | Stonking Stingray | Interim | 26.10 (Oct 2026) | Jul 2027 |
| 26.04 | Resolute Raccoon | LTS | 26.04.1 (Aug 2026) | May 2031 |
| 24.04 | Noble Numbat | LTS | 24.04.5 (Sep 2026) | Jun 2029 |
| 22.04 | Jammy Jellyfish | LTS | 22.04.5 (Sep 2024) | Jun 2027 |
| 20.04 | Focal Fossa | LTS | 20.04.6 (Mar 2023) | Ended May 2025 (ESM only) |
Interim releases such as 25.04 and 25.10 are already end-of-life — they only get nine months of support. If lsb_release reports anything not in the table above, that server is no longer receiving standard security updates. LTS releases past standard support can still get security patches through Ubuntu Pro's Expanded Security Maintenance (ESM).
The cross-distro answer: /etc/os-release
/etc/os-release is a standardised file (originally defined by systemd) that practically every modern distribution ships — including ones that don't use systemd, like Alpine. It needs no extra packages, so it's the right command to reach for in any script that might run across multiple distros (Ubuntu, Debian, AlmaLinux, Rocky, Fedora, Amazon Linux, Alpine) or inside a container:
cat /etc/os-release
PRETTY_NAME="Ubuntu 26.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="26.04"
VERSION="26.04.1 LTS (Resolute Raccoon)"
VERSION_CODENAME=resolute
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=resolute
LOGO=ubuntu-logo
To extract just one field — useful in shell scripts:
. /etc/os-release # source it as shell variables
echo "$ID $VERSION_ID" # ubuntu 26.04
echo "$VERSION_CODENAME" # resolute
ID is the lowercase distribution identifier (ubuntu, debian, almalinux, rocky, rhel, amzn, alpine), and VERSION_ID is the release version string — 26.04 on Ubuntu, 13 on Debian, 9.8 on AlmaLinux. Note that VERSION_ID never includes the Ubuntu point release; for that, read VERSION or PRETTY_NAME. Those two are the right pair to branch on in a portable deploy script — see the Linux distros for deployment guide for context on which IDs your servers might actually report.
hostnamectl — systemd's built-in
hostnamectl was designed for setting the hostname, but it also dumps OS metadata as a side effect:
hostnamectl
Static hostname: web-prod-01
Icon name: computer-vm
Chassis: vm
Machine ID: 7c3d8a9e2f1b4c6d8e0f1a2b3c4d5e6f
Boot ID: a1b2c3d4e5f60718293a4b5c6d7e8f90
Virtualization: kvm
Operating System: Ubuntu 24.04 LTS
Kernel: Linux 6.8.0-31-generic
Architecture: x86-64
It's the most informative single command — it tells you the distro version and the kernel and whether you're running in a VM. On any systemd host it works without extra packages installed, but it isn't available inside most containers (the official Ubuntu and Debian images don't include it), so don't use it in scripts that might run in Docker.
uname — kernel, not distro
uname reports the kernel, which is not the same thing as the distribution. Treating it as a distro check is one of the most common mistakes:
uname -a
Linux web-prod-01 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Thu May 30 21:00:00 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
The output mentions Ubuntu
, but that's part of the Ubuntu-specific kernel build identifier. On AlmaLinux or RHEL 9 you'd see .el9.x86_64 instead, and on Amazon Linux 2023 .amzn2023.x86_64. uname -r alone gives you the kernel version (6.8.0-31-generic), which matters when you're checking module compatibility, but it doesn't tell you whether the distro is Ubuntu 22.04 or 24.04.
Use uname for kernel-related decisions, not distribution-version decisions.
/etc/issue and /etc/issue.net — the legacy options
Some older guides recommend these:
cat /etc/issue
Ubuntu 26.04.1 LTS \n \l
The \n and \l are escape sequences expanded at login time (hostname and tty line). /etc/issue is what gets shown above the login prompt on a serial console. It's editable as a free-form file, so on hardened or customised systems it might contain a banner instead of the OS version. Don't rely on it in scripts — /etc/os-release is the right substitute.
Cross-distro examples — what you'll see on each
The output of /etc/os-release on the other distros covered earlier:
Debian 13:
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.7
ID=debian
Debian's VERSION_ID is just the major number. The current Debian 13 images also expose the point release in DEBIAN_VERSION_FULL.
AlmaLinux 9:
NAME="AlmaLinux"
VERSION="9.8 (Olive Jaguar)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.8"
PLATFORM_ID="platform:el9"
PRETTY_NAME="AlmaLinux 9.8 (Olive Jaguar)"
Amazon Linux 2023:
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PRETTY_NAME="Amazon Linux 2023.12.20261102"
PLATFORM_ID="platform:al2023"
Alpine 3.20:
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.20.3
PRETTY_NAME="Alpine Linux v3.20"
HOME_URL="https://alpinelinux.org/"
Notice that AlmaLinux and Amazon Linux both set ID_LIKE to fedora / rhel — that's the field to branch on when you want anything in the RHEL family
rather than a specific distro. Debian-derivatives (Ubuntu, Mint) set ID_LIKE=debian.
Scripting version checks in CI
A common pattern in deploy scripts: gate a step on the distro and version. The portable version:
#!/usr/bin/env bash
set -euo pipefail
. /etc/os-release
case "$ID" in
ubuntu|debian)
sudo apt-get update
sudo apt-get install -y nginx
;;
almalinux|rocky|rhel|fedora|amzn)
sudo dnf install -y nginx
;;
*)
echo "Unsupported distro: $ID" >&2
exit 1
;;
esac
For an exact-version check (some deploy steps only support specific versions):
. /etc/os-release
if [[ "$ID" == "ubuntu" && "$VERSION_ID" == "26.04" ]]; then
echo "Detected Ubuntu 26.04 — using the resolute apt source"
fi
The [[ ... ]] test compares VERSION_ID as a string, which is what you want — a version is a label, not a number. Bash arithmetic only handles integers, and treating versions as decimals (in awk or bc) breaks as soon as a minor number reaches two digits: as a decimal, RHEL 8.10 becomes 8.1 and sorts before 8.9.
For greater-than-or-equal checks, let the package manager's version logic do it instead of rolling your own:
if [[ "$ID" == "ubuntu" ]] && dpkg --compare-versions "$VERSION_ID" ge "24.04"; then
echo "Ubuntu 24.04 or newer"
fi
On RHEL-family systems (no dpkg), GNU sort -V gives the same version-aware ordering: printf '%s\n' "8.10" "8.9" | sort -V lists 8.9 first.
If you're copying a distro-branching script like this onto every server by hand, it belongs in your deploy instead: DeployHQ's SSH commands run scripts directly on your servers before or after each deployment, so the version check happens on every release rather than when someone remembers.
Container-specific: how cat /etc/os-release behaves inside containers
Inside a Docker container, cat /etc/os-release reports the image's distro, not the host's. A Debian-slim container running on an Amazon Linux host:
docker run --rm debian:12-slim cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
ID=debian
That's usually what you want — the script inside the container should see the container's filesystem. But it does mean what distro is this server?
gives different answers depending on whether you're asking the host or a container. The host answer comes from cat /etc/os-release on the bare metal; the container answer comes from inside docker exec.
For Kubernetes nodes, the right place to check the host OS is via the kubelet's nodeInfo field (kubectl get nodes -o wide) or by ssh'ing into the node directly.
Related deploys
Knowing your distro version unlocks the rest of the server-ops command set:
- Essential Linux server commands for deployment — disk space, memory, process and log inspection that come up every release.
- Deploying WordPress on a VPS — distro-version-specific install steps for the most common LAMP stack.
- Installing cPanel on Ubuntu 24.04 — Ubuntu version specificity matters here because cPanel only supports specific Ubuntu LTS releases.
- Installing Keycloak on a VPS — Ubuntu-targeted but the version-check pattern carries.
For deploys themselves, DeployHQ is distro-agnostic — the build pipelines feature runs your build inside a container, and the deploy lands on whichever Linux distribution your target servers happen to run. Start a free trial to wire any of these distros into a Git-driven deploy workflow.
Need help? Email support@deployhq.com or follow @deployhq on X.