Command To Check Version In Linux

6 min read

Command to Check Version in Linux

When you install a new Linux distribution or update your existing system, confirming the current version number ensures you are working with the intended release, verifies the integrity of downloaded packages, and helps you decide whether compatibility with other software or applications requires attention. This article walks you through the most reliable ways to retrieve the version information on Linux, from simple command‑line utilities to more detailed metadata sources. By following the step‑by‑step instructions, understanding what the numbers mean, and mastering optional flags, you’ll quickly become comfortable checking versions across Debian‑based, Red Hat‑based, and generic Linux environments.

Introduction

Knowing exactly which Linux version your machine is running is crucial for troubleshooting, security updates, and choosing the right tools. So, a quick glance at the version command can save hours of guesswork and prevent unexpected errors. Many services provide API keys tied to specific releases, while some hardware drivers only support certain kernels or package families. This overview covers the primary commands, explains the underlying data structures, highlights common variations, and answers frequent questions that arise during routine maintenance.

Basic Commands and Quick Checks

Uname – The Kernel Identifier

The simplest way to see the operating system’s core components is the uname utility. On virtually all Linux systems it returns a string that includes the kernel name, release version, architecture, and hostname. For example:

uname -a

Typical output looks like:

Linux mingw6.x86_64 gnu32 -v 5.4.0-34-amd64 #1 SMP Precision PPC

The fourth field (5.4.0-34) is the kernel version, while the third field indicates the architecture Most people skip this — try not to..

uname -r

which yields 5.4.0-34-generic. This single command works on most distros and gives you the latest kernel revision Worth keeping that in mind..

LsbRelease – Debian / Ubuntu Specifics

Debian‑derived distributions ship a file named /etc/lsb-release. Running the script provides human‑readable fields such as ID, NAME, DISTRIBUTION, and VERSION. Example:

cat /etc/lsb-release

or simply:

lsb_release -a

On Ubuntu 22.04 the output may read:

Name: Ubuntu
District: production
ID: ubuntu
Version: 22.04.3 LTS (Jammy Jellyfish)

Red Hat / CentOS Information

For Red Hat based systems the equivalent tool is redhat-release (also available as rhel-release). Execute:

redhat-release

If the command is not present, read the release file directly:

cat /etc/redhat-release

On Rocky Linux, AlmaLinux, Oracle Linux, and similar derivatives, the same file is usually available and may include a point release such as 9.3. For a more programmatic value, query the RPM database:

rpm -E %{rhel}

Fedora systems use their own release file:

cat /etc/fedora-release

These files are lightweight and reliable, but they are distribution-specific. For a portable approach, move on to the standard release metadata file described next.

The Universal Source: /etc/os-release

Most modern Linux distributions provide /etc/os-release, a plain-text file standardized by systemd and widely adopted across Debian, Ubuntu, Fedora, Red Hat, Arch, openSUSE, and many others. It is often the best single source for distribution name and version:

cat /etc/os-release

A typical result contains fields such as:

NAME="Ubuntu"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
ID=ubuntu
ID_LIKE=debian
VERSION_ID="22.04"
PRETTY_NAME="Ubuntu 22.04.3 LTS"

The most useful fields are usually PRETTY_NAME for display, ID for scripting, and VERSION_ID for comparisons. To extract just one value without

parsing the entire file, use grep and cut or, more cleanly, source the file in a shell script:

source /etc/os-release
echo "$PRETTY_NAME"
echo "$VERSION_ID"

Because the file is essentially a shell‑compatible key‑value list, sourcing it makes every variable immediately available to your scripts. For one‑liners, awk works well:

awk -F= '/^VERSION_ID=/{gsub(/"/,"",$2); print $2}' /etc/os-release

Using hostnamectl for a Unified View

On systems running systemd (which includes virtually all current major distributions), hostnamectl presents a concise summary that blends kernel, distribution, and hardware information:

hostnamectl

Output example:

Static hostname: web-01
Icon name: computer-vm
Chassis: vm
Machine ID: 4a3c2f1e8d7b4e9a8c6d5f3e2b1a0c9d
Boot ID: 7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
Operating System: Ubuntu 22.04.3 LTS
Kernel: Linux 5.15.0-91-generic
Architecture: x86-64
Hardware Vendor: QEMU
Hardware Model: Standard PC (Q35 + ICH9, 2009)

The Operating System line is drawn directly from /etc/os-release, while Kernel and Architecture come from uname. This makes hostnamectl an excellent single command for inventory scripts or quick manual checks Simple, but easy to overlook..

The Kernel’s Own Record: /proc/version

For the absolute kernel perspective—useful when you suspect a mismatch between the running kernel and installed packages—read /proc/version:

cat /proc/version

Typical output:

Linux version 5.15.0-91-generic (buildd@lcy02-amd64-045) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #101-Ubuntu SMP Tue Nov 14 13:32:37 UTC 2023

This reveals the exact compiler toolchain and build host, which can be critical when debugging kernel modules or verifying reproducible builds.

Graphical and Desktop Environments

If you are on a desktop installation, the same information is exposed through GUI tools. GNOME’s Settings → About, KDE’s System Settings → About System, and similar panels in Xfce, MATE, or Cinnamon all read from /etc/os-release and uname under the hood. They are convenient for quick visual confirmation but are not scriptable Less friction, more output..

Choosing the Right Tool

Scenario Recommended Command
Quick kernel version uname -r
Distribution name & version (portable) cat /etc/os-release or hostnamectl
Scriptable distribution ID source /etc/os-release && echo "$ID"
Red Hat family major version rpm -E %{rhel}
Full system summary (systemd systems) hostnamectl
Kernel build details cat /proc/version

Conclusion

Linux exposes its identity through several complementary interfaces, each suited to a different layer of the system. In real terms, the kernel reports itself via uname and /proc/version; the distribution brands itself in /etc/os-release (and the legacy /etc/*-release files); and systemd aggregates both into the convenient hostnamectl command. For portable scripts, /etc/os-release is the de facto standard—source it, read ID and VERSION_ID, and you have a reliable, parseable way to adapt behavior across Debian, Ubuntu, Fedora, RHEL, Arch, openSUSE, and countless derivatives. Here's the thing — for interactive use, hostnamectl gives the most complete picture in a single, readable block. Knowing which source to query eliminates guesswork and makes system inventory, automation, and troubleshooting straightforward on any Linux machine Small thing, real impact. But it adds up..

Just Made It Online

New on the Blog

Picked for You

We Thought You'd Like These

Thank you for reading about Command To Check Version In Linux. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home