Use cat /etc/os-release first if you need the Linux distribution version on Ubuntu or Debian. It is the most consistent method across modern releases, it works well in scripts, and it clearly separates the operating system name from the kernel version. If you only remember one command, remember that one.
TLDR: On Ubuntu, run cat /etc/os-release or lsb_release -a to check the installed version, such as Ubuntu 22.04.4 LTS. On Debian, cat /etc/os-release is also the safest choice, while cat /etc/debian_version gives a shorter Debian release value. For example, a support team managing 120 Linux servers can identify mismatched releases in under 2 minutes with /etc/os-release, instead of checking each machine manually through panels or notes. In most audits, this avoids basic reporting errors that often affect 5% to 10% of mixed Ubuntu and Debian fleets.
Best command to check the Ubuntu version
The most reliable command is:
cat /etc/os-releaseTypical output on Ubuntu looks like this:
NAME="Ubuntu"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 22.04.4 LTS"
VERSION_ID="22.04"The line you usually want is PRETTY_NAME. It gives a clean human-readable version. The VERSION_ID line is better for scripts because it keeps the value short and predictable.

Another common Ubuntu command is:
lsb_release -aIt may return:
Distributor ID: Ubuntu
Description: Ubuntu 24.04.1 LTS
Release: 24.04
Codename: nobleThis is clear and easy to read. The catch is that lsb_release may not be installed on minimal containers or stripped-down cloud images. That is annoying during remote troubleshooting, especially when a simple version check turns into package installation work. /etc/os-release avoids that problem most of the time.
Ubuntu vs Debian: what changes when checking versions?
Ubuntu is based on Debian, but the version scheme is different. Ubuntu uses a date-based format, such as 20.04, 22.04, or 24.04. The first number is the year. The second number is the month. For example, 22.04 means April 2022.
Debian uses release numbers and codenames, such as 11 bullseye, 12 bookworm, or 13 trixie. Debian can also show point releases, such as 12.5. This matters when applying vendor support rules, security baselines, or package compatibility checks.
On Ubuntu, this command is usually enough:
cat /etc/os-releaseOn Debian, use the same command first:
cat /etc/os-releaseYou can also check:
cat /etc/debian_versionThat file may show something like:
12.5It is short, but it does not always give the full marketing name or codename. For a full report, prefer /etc/os-release.
Why uname is not enough
Many users run:
uname -aThis shows the kernel version, architecture, and build details. It does not reliably show the Ubuntu or Debian release. For example, an Ubuntu 22.04 server may run a newer hardware enablement kernel. A Debian server may run a backported kernel. The kernel can change while the distribution release stays the same.
Use uname -r only when you need the kernel version:
uname -rFor example:
6.8.0-45-genericThat tells you about the kernel. It does not tell you whether the system is Ubuntu 24.04, Ubuntu 22.04, Debian 12, or something else.
Fast command list for Ubuntu and Debian
- Best general command:
cat /etc/os-release - Ubuntu-friendly command:
lsb_release -a - Debian short version:
cat /etc/debian_version - Kernel only:
uname -r - System summary:
hostnamectl
The hostnamectl command can also help:
hostnamectlIt often prints the operating system, kernel, architecture, hostname, and virtualization status. This is useful on servers because it gives more context without running several commands. Still, for clean version detection, /etc/os-release remains the better source.

How to check the version in a script
For automation, do not parse random command output if you can avoid it. Use the structured values in /etc/os-release. A simple shell snippet looks like this:
. /etc/os-release
echo "$PRETTY_NAME"To check only the distribution ID and version, use:
. /etc/os-release
echo "$ID $VERSION_ID"This may print:
ubuntu 22.04Or:
debian 12This format is much easier to compare in scripts. It also reduces problems caused by spacing, codenames, or translated output.
Common mistakes when checking Linux versions
- Mistaking the kernel for the distribution:
unameshows the kernel, not the Ubuntu or Debian release. - Trusting old documentation: Server notes can be stale after upgrades.
- Assuming Ubuntu and Debian use the same release names: They do not.
- Depending only on
lsb_release: It may be missing on minimal systems. - Ignoring containers: A container can report Debian while the host runs Ubuntu, or the other way around.
Honestly, it feels like version checks should be too simple to get wrong. Yet they still waste time. A five-second command can prevent bad package installs, failed upgrade plans, and support tickets sent to the wrong vendor queue.
Practical Ubuntu and Debian examples
If a vendor asks for your Ubuntu version, send this output:
cat /etc/os-releaseThen copy the PRETTY_NAME line. For example:
PRETTY_NAME="Ubuntu 22.04.4 LTS"If a security auditor asks for Debian release evidence, provide:
cat /etc/os-release
cat /etc/debian_versionThis gives both the full identity and the compact Debian release value. It is clear, repeatable, and easy to record.

Recommended order for checking versions
- Run
cat /etc/os-release. - Check
PRETTY_NAME,ID, andVERSION_ID. - On Ubuntu, use
lsb_release -aif you want a readable second source. - On Debian, use
cat /etc/debian_versionif you need the Debian point release. - Use
uname -ronly for the kernel version.
The safest rule is simple: use /etc/os-release for the operating system, and use uname for the kernel. Ubuntu and Debian are closely related, but their release formats are not the same. Treat them as separate systems when reporting versions, planning upgrades, or checking support status.