Unlike Windows, which usually only maintains two active operating systems at any given time (Windows 10 and 11), the Linux ecosystem is vastly more complex. Canonical (the company behind Ubuntu) maintains multiple different versions of Ubuntu simultaneously. Every two years they release a Long Term Support (LTS) version designed for enterprise stability, while releasing smaller, experimental versions every six months.
If you are trying to follow a complex tutorial online to install a web server or a database, the commands will often fail catastrophically if you are running the wrong version of Ubuntu. You must know exactly what version your server is running before you execute any installation scripts.
Method 1: The lsb_release Command (The Most Detailed Output)
The Linux Standard Base (LSB) command is the absolute best way to check your OS version because it prints the information in a clean, human-readable format designed specifically to answer this exact question.
- Open your terminal (or connect to your remote server via SSH).
- Type the following command and press Enter:
lsb_release -a
The -a flag stands for “all,” instructing the system to print the complete release profile. The terminal will spit out a four-line response that looks like this:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 22.04.3 LTS Release: 22.04 Codename: jammy
The Description line tells you exactly what you need to know: you are running version 22.04 (the third patch), and it is an LTS (Long Term Support) release. The Codename (“jammy” for Jammy Jellyfish) is also incredibly important, as many advanced software repositories require you to use the codename instead of the version number when downloading packages.
Method 2: Querying the os-release File (The Universal Method)
If you are using an incredibly stripped-down, minimal installation of Ubuntu (like a Docker container), the lsb_release utility might not actually be installed, and the terminal will throw a “command not found” error. You must bypass the utility and read the raw operating system files directly.
- Type the following command to print the contents of the core system release file:
cat /etc/os-release
This will dump a dozen lines of raw variable data onto the screen (e.g., PRETTY_NAME="Ubuntu 22.04.3 LTS", VERSION_ID="22.04"). While slightly messier than Method 1, it contains the exact same critical version numbers and codenames.
Because the /etc/os-release file is a required standard across almost all modern Linux distributions (systemd), this command is universally reliable. It will work on Ubuntu, Debian, CentOS, and Alpine Linux, making it a powerful tool for a system administrator bouncing between different server environments.
Method 3: The hostnamectl Command
If you are running a modern system (Ubuntu 16.04 or newer), you can leverage the built-in systemd toolset to grab the version number alongside other useful hardware data.
- Type the following command:
hostnamectl
This command is primarily used to check the machine’s network name, but it also prints a highly detailed block of diagnostic information. Look for the line labeled Operating System. It will clearly display your current Ubuntu version, alongside your underlying Kernel version and the server’s processor architecture (e.g., x86_64 or ARM).