How to check your Ubuntu version from the command line - Static

  [ Rocketeers ](/)   

[Login](https://app.rocketeersapp.com) 

 On this page

 Knowledge
---------

How to check your Ubuntu version from the command line
======================================================

### [\#CommandLine](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/command-line)

A quick guide to checking which Ubuntu release and kernel you're running, using lsb\_release, /etc/os-release, hostnamectl and uname.

 Published by [Mark van Eijk](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/author/mark-van-eijk) on June 23, 2026 
Updated on June 30, 2026 · 2 minute read

1. [Why you need to know your Ubuntu version](#content-why-you-need-to-know-your-ubuntu-version)
2. [The quickest answer: lsb\_release](#content-the-quickest-answer-lsbrelease)
3. [Reading /etc/os-release](#content-reading-etcos-release)
4. [The old-school /etc/issue](#content-the-old-school-etcissue)
5. [A richer view with hostnamectl](#content-a-richer-view-with-hostnamectl)
6. [Checking the kernel version](#content-checking-the-kernel-version)
7. [Which one should you use?](#content-which-one-should-you-use)

[\#](#content-why-you-need-to-know-your-ubuntu-version "Permalink")Why you need to know your Ubuntu version
-----------------------------------------------------------------------------------------------------------

Before I install a package, follow a tutorial, or open a support ticket, I want to know exactly which Ubuntu release I'm on. The version decides which package versions are available, which docs apply, and whether a release is still getting security updates. Here are the commands I reach for.

[\#](#content-the-quickest-answer-lsbrelease "Permalink")The quickest answer: lsb\_release
------------------------------------------------------------------------------------------

My go-to is `lsb_release`, which prints the distributor info in a clean format:

 ```
lsb_release -a

```

The `-a` flag means "all". You'll get the distributor ID, a description like `Ubuntu 24.04.2 LTS`, the release number (`24.04`), and the codename (`noble`). If you only want the number, use `-r`, and `-c` gives just the codename:

 ```
lsb_release -r
lsb_release -c

```

[\#](#content-reading-etcos-release "Permalink")Reading /etc/os-release
-----------------------------------------------------------------------

`lsb_release` isn't installed on every minimal image, but `/etc/os-release` always is. It's a plain file you can just print:

 ```
cat /etc/os-release

```

This shows `VERSION_ID`, `VERSION_CODENAME`, and `PRETTY_NAME`. Because it's structured as shell variables, scripts can source it directly, which makes it handy in automation.

[\#](#content-the-old-school-etcissue "Permalink")The old-school /etc/issue
---------------------------------------------------------------------------

For a fast glance, `/etc/issue` holds the text shown before login:

 ```
cat /etc/issue

```

It prints something like `Ubuntu 24.04.2 LTS \n \l`. The `\n` and `\l` are placeholders the login prompt fills in, so just ignore them.

[\#](#content-a-richer-view-with-hostnamectl "Permalink")A richer view with hostnamectl
---------------------------------------------------------------------------------------

`hostnamectl` gives the OS plus the hostname, architecture, and kernel in one go:

 ```
hostnamectl

```

I like this one on servers because the "Operating System" and "Kernel" lines tell me almost everything at a glance.

[\#](#content-checking-the-kernel-version "Permalink")Checking the kernel version
---------------------------------------------------------------------------------

The Ubuntu release and the kernel are separate things. To see the running kernel, use `uname`:

 ```
uname -r

```

The `-r` flag prints just the kernel release, like `6.8.0-52-generic`. Want the full picture, including architecture and build date? Use `-a`:

 ```
uname -a

```

[\#](#content-which-one-should-you-use "Permalink")Which one should you use?
----------------------------------------------------------------------------

For everyday use, `lsb_release -a` is the friendliest. On a stripped-down container or cloud image where it's missing, fall back to `cat /etc/os-release`. And when you're chasing a driver or hardware issue, `uname -r` is the kernel detail that actually matters.

Once you know your version, you'll likely want to [update Ubuntu from the command line](/update-ubuntu-command-line) to pull in the latest security patches. While you're sizing up a server, also check [how much RAM it has](/how-much-memory-on-ubuntu) and [how many CPU cores](/how-many-cpu-cores-on-ubuntu). See also the quick [Ubuntu version commands](/ubuntu-version).

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

Frequently asked questions
--------------------------

 How do I get just the Ubuntu codename? Run lsb\_release -c for the codename on its own (for example "noble" for 24.04). On minimal images without lsb\_release, use grep VERSION\_CODENAME /etc/os-release instead.

How do I check whether Ubuntu is 64-bit? Run uname -m. x86\_64 means 64-bit Intel/AMD and aarch64 means 64-bit ARM, while i686 or i386 would be 32-bit. dpkg --print-architecture shows the architecture Ubuntu installs packages for (amd64, arm64).

What's the difference between the Ubuntu version and the kernel version? The Ubuntu version (such as 24.04) is the distribution release and follows Ubuntu's own schedule. The kernel version (such as 6.8.0-52-generic, from uname -r) is the Linux kernel shipped with it and is updated independently, so the two numbers never match.

How do I check the Ubuntu version inside a script? Source the always-present /etc/os-release file and read its variables: run . /etc/os-release and then use $VERSION\_ID ("24.04") or $VERSION\_CODENAME ("noble"). This avoids depending on lsb\_release, which isn't installed on every image.

How do I check the Ubuntu version on a remote server? Connect with SSH, then run lsb\_release -a or hostnamectl on the server. To get it in one line without an interactive session, run ssh user@host "cat /etc/os-release".

#### More in [\#CommandLine](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/command-line)

- [Argument list too long (Bash: /bin/rm)](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/argument-list-too-long)
- [How to install Composer packages locally](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/install-composer-packages-locally)
- [How to copy files over SSH with scp](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/copy-files-over-ssh-scp)
- [How to search file contents with grep](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/search-files-grep-command)
- [How to create and extract tar archives in Linux](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/create-extract-tar-archives-linux)
- [How to install the Xcode Command Line Tools on macOS](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/install-xcode-command-line-tools)

 [View all 21 articles →](https://b20e6934-72ed-4c4f-aae8-685ca8f9a4f9.rocketeers.cloud/command-line)
