LINUX / TUTORIAL

How to check your Ubuntu version

Three quick command-line methods to find out which Ubuntu version your server is running — plus the lazy way using Claude Code on BareMetalServer.ai.

· 3 min read

Need to know which Ubuntu version your server is running? Maybe you're troubleshooting a compatibility issue, verifying an OS upgrade, or checking whether you're on an LTS release before installing software. Here are the three standard methods that work on every Ubuntu installation — plus a shortcut that skips the terminal entirely.

Method 1: lsb_release (the cleanest output)

The lsb_release command is part of the Linux Standard Base package and gives you the cleanest, most readable version info:

lsb_release -a

Output looks like this:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.5 LTS
Release:        22.04
Codename:       jammy

If you just want the version number without the extra info, use -d for description or -r for release number:

lsb_release -d
# Description: Ubuntu 22.04.5 LTS

lsb_release -r
# Release: 22.04

If lsb_release isn't installed (rare, but possible on minimal installations), you can install it with: sudo apt install lsb-release. Or use Method 2 instead.

Method 2: /etc/os-release (works on every Linux)

Every modern Linux distribution has the /etc/os-release file. This method works even on minimal containers and embedded systems where lsb_release isn't available:

cat /etc/os-release

Output:

PRETTY_NAME="Ubuntu 22.04.5 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.5 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
UBUNTU_CODENAME=jammy

To grab just the version, you can pipe it through grep:

grep VERSION_ID /etc/os-release
# VERSION_ID="22.04"

Method 3: hostnamectl (systemd-based)

The hostnamectl command is part of systemd and shows you system information including the OS version, kernel, and architecture:

hostnamectl

Output:

Static hostname: my-server
      Icon name: computer-vm
        Chassis: vm
     Machine ID: ba73ef45...
        Boot ID: 8f2a3c1d...
 Virtualization: kvm
Operating System: Ubuntu 22.04.5 LTS
         Kernel: Linux 5.15.0-119-generic
   Architecture: x86-64

This is my favorite when I need both the Ubuntu version AND the kernel version at the same time.

Bonus: Check from the kernel itself

If you only have uname available (on very minimal systems), you can at least get the kernel version:

uname -a
# Linux my-server 5.15.0-119-generic #129-Ubuntu SMP...

This won't tell you the Ubuntu release version, but it tells you the kernel, which is often enough to narrow things down.

Which method should you use?

  • lsb_release -a — Best for readability when troubleshooting
  • cat /etc/os-release — Best for scripts (always available)
  • hostnamectl — Best when you want kernel info too

All three work identically on Ubuntu 20.04, 22.04, 24.04, and every modern release. On BareMetalServer.ai, every Ubuntu deployment ships with lsb_release pre-installed, so Method 1 always works out of the box.

SKIP THE COMMANDS

Or just ask Claude on your server.

BareMetalServer.ai includes a built-in web terminal with Claude Code. Skip the documentation lookups — tell Claude what you need and it runs the commands directly on your server.

"Check Ubuntu version and update all packages"
"Install Docker and pull the latest nginx image"
"Set up a cron job to backup my database every 6 hours"

Claude runs commands, explains what it did, and fixes errors automatically. No SSH client, no memorizing flags, no documentation lookups.

Deploy a bare metal server in 5 minutes.

Full root access, NVMe storage, up to 100TB bandwidth. From $449/mo. Cancel anytime.