The Quick Answer: lsb_release
lsb_release -a
The output has four lines: Distributor ID (Ubuntu), Description (the full name with the point release and LTS), Release (the number, such as 24.04), and Codename (such as noble). On some releases a line saying that no LSB modules are available comes first; it is harmless.
For one value only, use the short options: lsb_release -rs prints the release number, lsb_release -cs the codename. If the command is missing on a minimal image, install it with sudo apt install lsb-release, or use the file below, which is always there.
The File That Is Always There
cat /etc/os-release
This file exists on every current Linux distribution. The lines that matter:
| Line | Meaning |
|---|---|
PRETTY_NAME | Full name with point release |
VERSION_ID | Release number, such as 24.04 |
VERSION_CODENAME | Codename, such as noble |
ID | Distribution, here ubuntu |
In a shell script, load the file and read the variables directly:
. /etc/os-release
echo "$ID $VERSION_ID"
hostnamectl
hostnamectl
Besides the host name, it shows the Operating System line with the full Ubuntu name and the Kernel line with the running kernel. It is handy when you want the system, the kernel, and the virtualization type on one screen.
/etc/issue
cat /etc/issue
This is the text shown before a console login. It normally contains the Ubuntu name and point release, but an administrator can change it, so treat it as a hint rather than the source of truth.
The same commands work on Debian: /etc/os-release and hostnamectl are always available there, and lsb_release needs the lsb-release package. Debian also has /etc/debian_version. The differences between the two systems are in Debian vs Ubuntu Server.
How to Read the Number
- Year and month: 24.04 was released in April 2024. Every Ubuntu release is numbered this way.
- Point release: 24.04.1, 24.04.2, and so on are the same release with collected updates. A server kept up to date with apt moves through them on its own.
- LTS: the April release of every even year is a long-term support release, such as 22.04, 24.04, and 26.04.
LTS and Interim Releases
LTS releases get five years of standard security maintenance. The releases in between, numbered .10 or the April release of an odd year, are interim releases with nine months of support. For a server, choose an LTS release; an interim release has to be upgraded every few months to stay supported.
Codenames
| Release | Codename |
|---|---|
| 22.04 LTS | jammy (Jammy Jellyfish) |
| 24.04 LTS | noble (Noble Numbat) |
| 26.04 LTS | resolute (Resolute Raccoon) |
The short lowercase codename appears in apt sources and in many installation instructions, which is why lsb_release -cs is used in so many scripts.
The Kernel Is Not the Ubuntu Version
uname -r prints the Linux kernel version, a number such as 6.8 on 24.04 or 7.0 on 26.04, followed by a build number. It tells you nothing direct about the Ubuntu release, and a release can move to a newer kernel during its life. See how to check the kernel version.
Is a Newer Release Available?
do-release-upgrade -c
This only checks whether a newer release is available; it changes nothing. Take a snapshot before an actual release upgrade; snapshot vs backup explains which one you need.