How to Check Linux Ubuntu Version: Ubuntu vs Debian for Checking Linux Versions

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-release

Typical 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 -a

It may return:

Distributor ID: Ubuntu
Description:    Ubuntu 24.04.1 LTS
Release:        24.04
Codename:       noble

This 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-release

On Debian, use the same command first:

cat /etc/os-release

You can also check:

cat /etc/debian_version

That file may show something like:

12.5

It 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 -a

This 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 -r

For example:

6.8.0-45-generic

That 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:

hostnamectl

It 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.04

Or:

debian 12

This 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: uname shows 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-release

Then 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_version

This gives both the full identity and the compact Debian release value. It is clear, repeatable, and easy to record.

maintenance

Recommended order for checking versions

  1. Run cat /etc/os-release.
  2. Check PRETTY_NAME, ID, and VERSION_ID.
  3. On Ubuntu, use lsb_release -a if you want a readable second source.
  4. On Debian, use cat /etc/debian_version if you need the Debian point release.
  5. Use uname -r only 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.

Have a Look at These Articles Too

Published on October 10, 2026 by Ethan Martinez. Filed under: .

I'm Ethan Martinez, a tech writer focused on cloud computing and SaaS solutions. I provide insights into the latest cloud technologies and services to keep readers informed.