How to Check the OS Version in Linux: A Complete Guide
Knowing how to check the OS version in Linux is a fundamental skill that every system administrator, developer, and even casual user should master. Because of that, whether you are troubleshooting compatibility issues, verifying software requirements, or simply curious about what system you are running, identifying your Linux distribution and its version number is the first step toward effective system management. This guide walks you through every reliable method available, complete with explanations and practical examples.
Why Checking Your Linux OS Version Matters
Before diving into the methods, it helps to understand why this information is so important. Linux exists in dozens of distributions — Ubuntu, Fedora, CentOS, Debian, Arch, and many more — each with its own versioning scheme and release cycle. Software packages, kernel updates, and security patches are all tied to specific OS versions.
The moment you encounter a bug, deploying a fix often depends on knowing exactly which version of the operating system you are working with. Practically speaking, similarly, when installing new software, many applications list minimum OS version requirements. Without this knowledge, you risk installing incompatible packages or missing critical security updates. Checking your Linux OS version also becomes essential when documenting server environments, performing audits, or migrating systems between hardware platforms Most people skip this — try not to..
Real talk — this step gets skipped all the time.
Method 1: Using the /etc/os-release File
The most universal and modern method is reading the /etc/os-release file. This file is part of the systemd project and is present on virtually every contemporary Linux distribution, including Ubuntu, Fedora, Debian, CentOS 7+, and Arch Linux.
To view its contents, open your terminal and type:
cat /etc/os-release
The output will display several key fields:
- NAME — the official name of the distribution (e.g., Ubuntu, Fedora Linux)
- VERSION — the full version string including codename (e.g., "22.04.3 LTS (Jammy Jellyfish)")
- VERSION_ID — the numeric version identifier (e.g., 22.04)
- ID — a short lowercase identifier used by scripts (e.g., ubuntu)
- PRETTY_NAME — a human-readable combined string of the name and version
- BUILD_ID — the build identifier assigned by the distribution maintainers
- HOME_URL and BUG_REPORT_URL — links to the distribution's support pages
This method is preferred because it is standardized. Scripts and automation tools can reliably parse these fields without depending on third-party utilities. If you only want the version ID, you can use:
cat /etc/os-release | grep VERSION_ID
Or more precisely:
. /etc/os-release && echo $VERSION_ID
This second approach sources the file as a shell script, making its variables directly accessible for use in your commands.
Method 2: Using the lsb_release Command
Another popular approach involves the lsb_release utility, which stands for Linux Standard Base release information. This tool provides standardized information about your distribution and is especially common on Debian-based systems like Ubuntu and Linux Mint.
To use it, simply run:
lsb_release -a
The output includes:
- Distributor ID — the name of the distribution
- Description — a detailed description including version and codename
- Release — the version number
- Codename — the internal codename assigned by the distribution team
If the command returns an error stating that the package is not found, you can install it easily. On Ubuntu or Debian, run:
sudo apt install lsb-release
On Fedora or RHEL-based systems:
sudo dnf install redhat-lsb-core
The advantage of lsb_release is its clean, consistently formatted output. It is particularly useful when writing scripts that need to detect the distribution type and version simultaneously.
Method 3: Using the uname Command for Kernel Information
While the methods above focus on the distribution version, sometimes you specifically need to know the kernel version your system is running. The uname command is the standard tool for this purpose.
To check your kernel version, run:
uname -r
This returns something like 5.15.0-76-generic. Each segment carries meaning:
- 5 — the major kernel version (currently in the 5.x or 6.x series for most distributions)
- 15 — the minor version within that major release
- 0 — the patch level
- 76 — the build number specific to your distribution
- generic — the flavor or build variant
For even more detailed system information, use:
uname -a
This flag displays everything in one line: kernel name, hostname, kernel version, machine hardware name, processor type, operating system, and more. If you want just the operating system name, use uname -s, and for the hardware platform, use uname -m But it adds up..
It is important to distinguish between the kernel version and the distribution version. To give you an idea, Ubuntu 22.That's why two systems can run the same kernel but have entirely different distributions. 04 and Debian 12 might both use kernel 6.1, yet they are distinct operating systems with different package managers and default software But it adds up..
Easier said than done, but still worth knowing.
Method 4: Using hostnamectl on Systemd-Based Systems
On any Linux distribution that uses systemd as its init system — which includes most modern distributions — the hostnamectl command provides a convenient summary of system information Worth keeping that in mind..
Run the following:
hostnamectl
The output typically includes:
- Static hostname — your computer or server's name
- Icon name — a visual icon associated with the device type
- Chassis — the hardware type (e.g., desktop, server, vm)
- Machine ID — a unique identifier for the system
- Boot ID — the identifier for the current boot session
- Operating System — the full name and version of your Linux distribution
- Kernel — the running kernel version
- Architecture — the system architecture (e.g., x86-64)
We're talking about arguably the most visually complete method, as it combines both distribution and kernel information in a single, well-formatted output. It works on Ubuntu 16.04 and later, Fedora 20+, CentOS 7+, and other systemd-based distributions Easy to understand, harder to ignore..
Method 5: Checking Release Files Directly
Older or more traditional Linux distributions may not have the /etc/os-release file. In such cases, you can check distribution-specific release files directly. Each distribution tends to maintain its own file:
- Debian:
cat /etc/debian_version - Red Hat / CentOS / Fedora:
cat /etc/redhat-release - SUSE / openSUSE:
cat /etc/SuSE-releaseorcat /etc/os-release - Arch Linux:
cat /etc/arch-release - Gentoo:
cat /etc/gentoo-release
You can also use a wildcard to check all release files at once:
cat /
```bash
cat /etc/*-release
The command above expands to every file in /etc whose name ends with ‑release, allowing you to view the contents of Debian’s debian_version, Red Hat’s redhat-release, SUSE’s SuSE-release, and any other distribution‑specific release descriptor without having to remember each individual filename Took long enough..
Additional one‑liners for quick checks
-
Kernel‑specific details
cat /proc/versionThis file reports the exact kernel build, compiler used, and any patches applied.
-
Distribution identifier only
lsb_release -siThe ‑si flags suppress the description and print just the short identifier (e.g., “Ubuntu”, “CentOS”, “Arch”).
-
Hostname verification
hostnameUseful when you need to confirm the name the system presents on the network.
Choosing the right method
- For a complete, human‑readable summary that includes both OS and kernel information,
hostnamectlremains the most convenient on systemd‑based platforms. - When you need raw, machine‑parsable data (for scripts), reading
/etc/os-releaseor/etc/*-releasedirectly is reliable. - In environments where lsb_release is unavailable, the combination of
/proc/versionand the various ‑release files provides a fallback.
Conclusion
Linux offers several built‑in tools to discover which distribution and kernel are running on a given machine. Think about it: the /etc/os-release file is the de‑facto standard for modern distributions, while legacy systems often expose their identity through files such as /etc/debian_version or /etc/redhat-release. Commands like uname, hostnamectl, and lsb_release complement these files by delivering concise or detailed output made for different use cases. By selecting the appropriate method for the task at hand, administrators and developers can reliably gather the system information they need without resorting to external utilities.