Knowing exactly which Linux distribution and kernel you are running is fundamental to system administration, troubleshooting, and software compatibility. Whether you are applying security patches, installing proprietary drivers, or simply following a tutorial that requires a specific kernel version, the ability to quickly identify your environment saves hours of frustration. Because Linux is a modular ecosystem—combining a kernel, a distribution (distro), and a desktop environment—there is no single "version number" that tells the whole story. Instead, you need a toolkit of commands to peel back the layers.
Understanding What "Linux Version" Actually Means
Before diving into commands, it helps to clarify the terminology. When users ask for the "Linux version," they are usually looking for one of three distinct pieces of information:
- The Kernel Version: This is the core version of the Linux kernel itself (e.g.,
6.5.0-14-generic). It dictates hardware support, filesystem capabilities, and system call interfaces. - The Distribution Release: This identifies the specific OS vendor and release (e.g., Ubuntu 22.04 LTS, Fedora 39, Debian 12 "Bookworm"). This determines your package manager, default software versions, and support lifecycle.
- The Desktop Environment Version: (Optional but relevant) The version of GNOME, KDE Plasma, XFCE, or others, which affects UI features and extension compatibility.
Most commands below will reveal one or more of these layers.
The Universal Standard: /etc/os-release
The single most reliable, distribution-agnostic method for identifying your operating system is reading the /etc/os-release file. This file is part of the systemd standard and is present on virtually every modern Linux distribution, including Ubuntu, Debian, Fedora, RHEL, CentOS, Arch, openSUSE, and Alpine.
Run the following command:
cat /etc/os-release
You will receive a structured output containing key-value pairs:
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
Why this is the gold standard:
- Machine Parseable: Scripts and automation tools (like Ansible or Docker entrypoint scripts) rely on
IDandVERSION_IDto make decisions. - Consistent: Unlike
/etc/redhat-releaseor/etc/lsb-release(which are distro-specific), this file exists everywhere systemd exists (which is almost everywhere now). - Detailed: It provides the codename (
jammy,bookworm,noble), which is essential for adding third-party repositories.
If you only need the pretty name for a quick glance, use grep:
grep PRETTY_NAME /etc/os-release
The LSB Alternative: lsb_release
For years, the Linux Standard Base (LSB) provided the lsb_release command as the cross-distro standard. While /etc/os-release has largely superseded it, lsb_release is still widely used in documentation and older scripts because its output is clean and human-readable by default It's one of those things that adds up..
Run:
lsb_release -a
Output example:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
Note: On minimal installations (like Docker containers or minimal Arch installs), the lsb_release package (lsb-release on Debian/Ubuntu, redhat-lsb on RHEL/Fedora) might not be installed by default. In those cases, /etc/os-release remains your fallback.
Checking the Kernel Version: uname
The uname (Unix Name) command prints system information. It does not tell you if you are on Ubuntu or Fedora; it tells you exactly which kernel binary is currently running in memory. This is critical for debugging hardware issues, checking for specific kernel vulnerabilities (CVEs), or verifying if a reboot is required after a kernel update.
The Most Common Flags
| Flag | Meaning | Example Output |
|---|---|---|
-r |
Kernel Release (The version number) | 6.5.0-14-generic |
-v |
Kernel Version (Build timestamp/config) | #14-Ubuntu SMP PREEMPT_DYNAMIC |
-s |
Kernel Name | Linux |
-m |
Machine Hardware Name (Architecture) | x86_64, aarch64 |
-a |
All information combined | (See below) |
You'll probably want to bookmark this section.
Quick check (most used):
uname -r
Full system summary:
uname -a
Output:
Linux my-laptop 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC x86_64 x86_64 x86_64 GNU/Linux
Breakdown: Hostname (my-laptop), Kernel Release (6.5.0-14-generic), Kernel Version (#14...), Architecture (x86_64 repeated for hardware/platform/OS), OS (GNU/Linux) Not complicated — just consistent..
The /proc/version Virtual File
Linux exposes kernel information via the virtual /proc filesystem. Worth adding: reading /proc/version gives you the kernel version string plus the compiler (GCC) version used to build it. This is occasionally useful for debugging kernel module compilation issues (vermagic matching) That's the part that actually makes a difference..
cat /proc/version
Output:
Linux version 6.5.0-14-generic (buildd@lcy02-amd64-047) (gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0, GNU ld (GNU Binutils for Ubuntu) 2.41) #14-Ubuntu SMP PREEMPT_DYNAMIC
Distribution-Specific Shortcuts (Legacy & Convenience)
While /etc/os-release works everywhere, veteran administrators often use distro-specific files for muscle memory or because they appear in older runbooks Nothing fancy..
Red Hat Family (RHEL, CentOS, Fedora, Rocky, AlmaLinux)
cat /etc/redhat-release
# Output: Rocky Linux release 9.3 (Blue Onyx)
On newer Fedora/RHEL 8+, this file is often a symlink to /etc/os-release or /etc/system-release Most people skip this — try not to. Still holds up..
Debian Family (Debian, Ubuntu, Mint, Kali)
cat /etc/debian_version
# Output: 12.5
This only gives the major/minor version number (e.g., 12.5), not the codename ("Bookworm"). For the codename, you still need /etc/os-release or lsb_release Turns out it matters..
Arch Linux
Arch is a rolling release; it doesn't have discrete "versions" like 22.04 or 12.5