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 · 1 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.
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!
Related articles
Argument list too long (Bash: /bin/rm)
A quick guide to checking which Ubuntu release and kernel you're running, using lsb_release, /etc/os-release, hostnamectl and uname.
How to install Composer packages locally
A quick guide to checking which Ubuntu release and kernel you're running, using lsb_release, /etc/os-release, hostnamectl and uname.