How To Check Version Of Linux Os

7 min read

Knowing exactly which Linux distribution and kernel version you are running is fundamental for system administration, troubleshooting, and software compatibility. Worth adding: " Because Linux is just a kernel wrapped in countless different distributions (distros), there isn't a single universal button to press. Day to day, whether you are applying security patches, installing proprietary drivers, or seeking help on a forum, the first question is almost always: "What version are you on? Instead, administrators rely on a toolkit of standard commands and specific files that reveal the complete picture of the operating system environment.

Quick note before moving on.

The Quickest Universal Method: hostnamectl

On any modern Linux system running systemd (which includes Ubuntu, Debian, Fedora, RHEL, CentOS, Arch, and openSUSE), the hostnamectl command is the single most efficient way to get a comprehensive overview. It presents the operating system name, the specific version, the kernel release, and even hardware architecture in a clean, labeled format Took long enough..

Open your terminal and type:

hostnamectl

The output will look similar to this:

   Static hostname: myserver
         Icon name: computer-vm
           Chassis: vm
        Machine ID: a1b2c3d4e5f6...
           Boot ID: f6e5d4c3b2a1...
    Virtualization: kvm
  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)

This command is ideal because it separates the Operating System (the distro release) from the Kernel (the core Linux version), a distinction that often confuses beginners Less friction, more output..

The Standard Compliance Check: lsb_release

So, the Linux Standard Base (LSB) was created to standardize software structures across distributions. On the flip side, the lsb_release command queries this standard directly. It is exceptionally useful for scripting because the output is predictable and parseable.

To see all available information, use the -a (all) flag:

lsb_release -a

Typical output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy

Key flags for scripting:

  • -d or --description: Shows the full description line only (e.g., "Ubuntu 22.04.3 LTS").
  • -r or --release: Shows the release number only (e.g., "22.04").
  • -c or --codename: Shows the development codename (e.g., "jammy", "bookworm", "bullseye").

Note: On minimal installations (like Docker containers or minimal Arch), lsb_release might not be installed by default. You can usually install it via your package manager (e.g., apt install lsb-release or pacman -S lsb-release).

Reading the Source Files: /etc/os-release and /etc/*release

If you are on a system without systemd (like Devuan, Alpine Linux, or older SysVinit systems) or if the binary tools are broken, the definitive source of truth lives in the /etc directory. The modern standard is the /etc/os-release file, defined by the freedesktop.org specification. It is a simple key-value text file that you can read with cat.

cat /etc/os-release

Output example:

PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

This file is machine-readable and human-readable. It is the preferred method for containerized environments and automation tools (like Ansible or Puppet) to detect the host OS.

You may also encounter legacy files in /etc ending in -release or _version. Running cat /etc/*release or cat /etc/*version will dump the contents of all of them at once, which is a great "catch-all" command if you aren't sure which distro you are logged into.

cat /etc/*release

Checking the Kernel Version Specifically

Sometimes you don't care about the distribution (Ubuntu vs. Fedora) but strictly need the Linux Kernel version. This is critical when debugging hardware support, checking for specific kernel vulnerabilities (CVEs), or compiling kernel modules (like NVIDIA drivers or VirtualBox guest additions).

This is the bit that actually matters in practice.

The standard command is uname (Unix Name).

For the kernel release only:

uname -r

Output: 5.15.0-91-generic

For all kernel information (kernel name, hostname, release, version, machine, processor, hardware platform, OS):

uname -a

Output: Linux myserver 5.15.0-91-generic #101-Ubuntu SMP Tue Nov 14 13:30:08 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Breakdown of uname -a flags:

  • -s: Kernel name (Linux).
  • -n: Network node hostname.
  • -r: Kernel release (the version number you usually need).
  • -v: Kernel version (build timestamp and config info).
  • -m: Machine hardware name (e.g., x86_64, aarch64, armv7l).
  • -p: Processor type.
  • -i: Hardware platform.
  • -o: Operating System (GNU/Linux).

Alternatively, you can read the virtual filesystem /proc/version:

cat /proc/version

This provides the kernel version, the GCC version used to compile it, and the compilation timestamp Which is the point..

Distribution-Specific Commands

While the methods above work almost everywhere, major distribution families have their own historical tools that veterans often prefer Most people skip this — try not to..

Red Hat Family (RHEL, CentOS, Fedora, Rocky, AlmaLinux)

These systems traditionally use the /etc/redhat-release file.

cat /etc/redhat-release

Output: Rocky Linux release 9.3 (Blue Onyx)

Modern Fedora and RHEL 8/9 also support hostnamectl and /etc/os-release perfectly.

Debian Family (Debian, Ubuntu, Mint, Kali)

Debian-based systems historically used /etc/debian_version Simple, but easy to overlook..

cat /etc/debian_version

Output: 12.2 (This only gives the major/minor version, not the codename) That's the part that actually makes a difference..

For Ubuntu specifically, /etc/lsb-release is often present and detailed:

cat /etc/lsb-release

Arch Linux Family (Arch, Manjaro, EndeavourOS)

Arch is a rolling release, so it doesn't have a "version number" like 22.04 or 9.3. The "version" is effectively the date of the last update. The standard file is **`/

Arch‑based installations keep the “rolling‑release” philosophy, so there is no static version string like those found on Debian‑ or Red Hat‑derived systems. The most reliable source of release information is the /etc/os-release file, which follows the standard XDG format and is present on virtually every modern Linux distribution, including Arch and its derivatives:

. /etc/os-release
echo "$NAME $VERSION_ID"

Running the snippet above will print something akin to:

Arch Linux rolling release

Because Arch updates its packages continuously, the modification time of the kernel package in the pacman database is a practical proxy for the current kernel version. You can query it directly with pacman:

pacman -Qi linux | grep "Installed Size" -A2

The output contains a line such as Version : 6.Because of that, 9. 5-arch1-1, which is the exact kernel build that is currently installed.

Another handy tool for Arch users is checkupdates, part of the pacman-contrib package. It lists pending updates for all installed packages, allowing you to see at a glance whether a newer kernel is available:

checkupdates | grep ^linux

If you prefer a more visual approach, the neofetch or lscpu utilities will display the distribution name and kernel version together with system hardware details, which can be useful when documenting a fresh installation or troubleshooting driver compatibility.

Beyond the distribution‑specific files, a few universal commands work everywhere, regardless of the init system or package manager:

  • hostnamectl – queries the system’s host name, operating system, and kernel version via systemd’s D‑Bus interface. Example:

    hostnamectl | grep "Operating System"
    
  • lsb_release -a – leverages the Linux Standard Base specification to report distribution information; it is available on many Debian‑ and Red Hat‑based systems that ship the lsb-release package Practical, not theoretical..

  • rpm -qi base-release (or the equivalent dpkg -l | grep base) – on RPM‑based distributions, this prints the base package version, which often aligns with the OS release.

These commands complement the low‑level tools (cat /etc/*release, uname -r, /proc/version) already covered, giving you a complete toolbox for identifying both the operating system and the exact kernel you are running. By selecting the method that matches your environment—whether it’s a static file, a package query, or a systemd query—you can reliably ascertain the information you need for debugging, security assessments, or software compatibility checks.

Conclusion
Understanding how to extract the operating system and kernel details is a fundamental skill for any Linux user or administrator. The combination of distribution‑specific files (e.g., /etc/redhat-release, /etc/debian_version, /etc/os-release), generic utilities (uname, /proc/version), and package manager queries (pacman, rpm, dpkg) ensures that you can obtain accurate version data on virtually any system. Leveraging these tools not only streamlines routine diagnostics but also enhances security posture by enabling prompt responses to kernel‑related vulnerabilities and driver compatibility issues. With this knowledge in hand, you can confidently manage the diverse landscape of Linux distributions and maintain a solid, well‑documented environment.

Just Shared

Fresh Reads

Readers Went Here

Related Posts

Thank you for reading about How To Check Version Of Linux Os. 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