When you’re working on a Linux system, you eventually need to check what version you’re on. Maybe something’s failing to install. Maybe you’re scripting across several machines. Or maybe you’re helping someone debug a package issue and need to be sure you’re speaking the same language.
No matter the reason, the version info helps. Not just the distro name, but the release number, codename, and kernel. All of that lives in a few spots, and the terminal makes it easy to pull.
Let’s walk through the different ways to check, with real command outputs, some notes from distro use, and tips that have saved time for me and plenty of other sysadmins.
Why Version Clarity Saves You Headaches
Linux systems with similar names often behave differently once version numbers change. A tool that installs cleanly on Ubuntu 20.04 may return dependency errors on 22.04.
Some versions switch default Python versions, update systemd behavior, or change where configuration files live. Those shifts can break scripts, halt builds, or mislead troubleshooting efforts.
Version mismatches are also a common blocker in shared environments. Support teams and forums often start with one question: which version, exactly, is running? Having that answer avoids delays and steers the fix in the right direction.
cat /etc/os-release: The Fastest General Check
If you’re on any modern Linux system, this file is likely there. It tells you the distribution name, version, and codename.
Run:
cat /etc/os-release
Example output on Debian 12:
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
You’ll see a similar structure on Fedora, Ubuntu, Arch, Rocky, and others. It’s easy to grep from if you’re writing automation.
lsb_release -a: Good for Readability
This is a friendly way to get clean, readable output. Works well when you’re copying version info into documentation or a support thread.
Run:
lsb_release -a
On Ubuntu 22.04, you might see:
Distributor ID: Ubuntu
Description: Ubuntu 22.04.4 LTS
Release: 22.04
Codename: jammy
If the command fails, the package might be missing. On Debian-based systems, install it like this:
sudo apt install lsb-release
For Red Hat-based distros, try:
sudo yum install redhat-lsb-core
It’s not always preinstalled, but it’s worth adding on dev boxes or when working with mixed teams.
hostnamectl: For Kernel + OS at Once
If you’re using a system with systemd, you can grab both kernel and distro info from one command.
hostnamectl
Here’s an example from Fedora 39:
Operating System: Fedora Linux 39 (Workstation Edition)
Kernel: Linux 6.6.10-200.fc39.x86_64
Architecture: x86-64
This is useful when you’re SSH’d into a new server and need a quick sanity check on what environment you’ve dropped into.
uname -r: Kernel, No Frills
To just check the kernel version, and nothing else, use:
uname -r
You’ll get something like:
5.15.0-105-generic
This command works well when checking kernel-related issues like driver compatibility or module support. It shows the version currently in use, not what’s pending from a recent update. Rebooting may still be required for newer kernels to take effect.
cat /proc/version: Compiler Details Included
Want to know how your kernel was built, including which compiler and when? This one tells you:
cat /proc/version
Sample from a server running Ubuntu 20.04:
Linux version 5.15.0-105-generic (buildd@lcy02-amd64-014) (gcc version 9.4.0) #115~20.04.1-Ubuntu SMP
This isn’t something you’ll use every day, but it’s useful when you’re comparing environments or checking for specific compiler flags in the kernel build.
If Nothing Seems to Work
Not every tool comes installed, especially on minimal images or containers. If /etc/os-release is missing (very rare), or lsb_release throws a command-not-found error, here’s what else you can try:
- For Red Hat-based systems:
cat /etc/redhat-release
- For Debian-based systems:
cat /etc/debian_version
- For a last-ditch guess:
cat /etc/issue
Even stripped-down containers usually leave some clue behind; it’s just a matter of knowing where to look.
Final Thoughts
You can’t work with Linux seriously without knowing how to check version info. It helps with installing packages, writing scripts, debugging edge cases, and collaborating with teams who might be on something completely different.
For system admins, these checks are second nature. For developers, they can prevent wasted hours on version conflicts. Either way, it’s five seconds well spent.
Keep the commands handy. Once you’ve used them a few times, they’ll stick.