Knowledge
How to check your Ubuntu version from the command line
#CommandLine
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 on June 23, 2026
Updated on June 30, 2026 · 2 minute read
- Why you need to know your Ubuntu version
- The quickest answer: lsb_release
- Reading /etc/os-release
- The old-school /etc/issue
- A richer view with hostnamectl
- Checking the kernel version
- Which one should you use?
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.
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
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.
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.
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.
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
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 to pull in the latest security patches. While you're sizing up a server, also check how much RAM it has and how many CPU cores. See also the quick Ubuntu version commands.
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!
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".