A single terminal command reveals the operating system version running on your Linux machine. If you’re wondering how to find the OS version in Linux, you’re in the right place. This guide covers multiple methods, from simple commands to checking graphical interfaces, so you can always get the information you need quickly.
Why Knowing Your OS Version Matters
Knowing your Linux distribution and version is crucial for several reasons. It helps you install compatible software, apply the correct security patches, and troubleshoot system-specific issues. Without this knowledge, you might run commands or install packages that don’t work on your system.
Different Linux distributions (like Ubuntu, Fedora, or Debian) have different package managers and file structures. The version number tells you how recent your system is and what support lifecycle it’s under. For example, Ubuntu 20.04 LTS has long-term support, while Ubuntu 22.10 is a short-term release.
How To Find The Os Version In Linux
This section covers the most reliable and universally applicable methods. You can use these commands on almost any Linux distribution, from desktop to server editions.
Using The Hostnamectl Command
The hostnamectl command is part of systemd, which is used by most modern Linux distributions. It’s one of the easiest ways to get a comprehensive overview.
- Open a terminal window.
- Type the following command and press Enter:
hostnamectl
You’ll see output similar to this:
Static hostname: my-laptop
Icon name: computer-laptop
Chassis: laptop
Machine ID: abc123def456
Boot ID: ghi789jkl012
Operating System: Ubuntu 22.04 LTS
Kernel: Linux 5.15.0-91-generic
Architecture: x86-64
The “Operating System” line shows the distribution name and version. This command works on Fedora, CentOS, Debian, and many others.
Checking The Os-Release File
Every Linux system has a file at /etc/os-release that contains standardized information. You can view it with a simple cat command.
- Run this command in your terminal:
cat /etc/os-release
Output example:
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 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
The PRETTY_NAME line gives you the human-readable version. This file is present on almost all Linux distributions, making it a reliable fallback.
Using The Lsb-Release Command
The lsb_release command provides LSB (Linux Standard Base) information. It’s not installed by default on some minimal systems, but it’s widely available.
- First, check if it’s installed:
lsb_release -a
If you get a “command not found” error, install it using your package manager. For Debian/Ubuntu:
sudo apt install lsb-release
For Fedora/RHEL:
sudo dnf install redhat-lsb-core
Once installed, run it again:
lsb_release -a
Output:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy
The “Description” line shows the full version. This method is particularly useful for older systems that might not have hostnamectl.
Checking The Kernel Version
Sometimes you need the kernel version, not just the distribution version. The kernel is the core of the operating system.
- Use the
unamecommand:
uname -r
This outputs something like 5.15.0-91-generic. The first number (5) is the major version, the second (15) is the minor version, and the rest are patch and distribution-specific details.
For more detailed kernel info, use:
uname -a
This shows the kernel name, hostname, kernel release, kernel version, machine hardware, and operating system.
Graphical Methods For Desktop Users
If you’re using a Linux desktop environment, you don’t have to use the terminal. Here are some graphical ways to find your OS version.
Ubuntu And Gnome-Based Systems
On Ubuntu with GNOME desktop:
- Click on the “Activities” button or press the Super key (Windows key).
- Type “Settings” and open the Settings application.
- Scroll down to “About” in the left sidebar.
- Look for “OS name” and “Version” in the right pane.
You’ll see something like “Ubuntu 22.04 LTS” along with other system details like memory and processor.
KDE Plasma Desktop
On KDE Plasma:
- Click the application launcher (usually in the bottom-left).
- Search for “System Settings” and open it.
- Go to “About This System” (sometimes under “System Administration”).
- You’ll see the distribution name and version listed.
Other Desktop Environments
For Xfce, LXQt, or Cinnamon, the process is similar:
- Look for “System Settings” or “Control Center” in the application menu.
- Find an “About” or “System Info” section.
- The OS version is usually displayed prominently.
If you can’t find it, you can always fall back to the terminal methods above.
Distribution-Specific Commands
Some Linux distributions have their own unique commands for checking the version. Here are a few common ones.
Debian And Ubuntu
On Debian-based systems, you can also check the /etc/debian_version file:
cat /etc/debian_version
This shows the Debian version number (e.g., “11.6” for Debian 11). For Ubuntu, this file might show the underlying Debian version.
Red Hat Enterprise Linux And Fedora
On RHEL, CentOS, and Fedora, check the /etc/redhat-release file:
cat /etc/redhat-release
Output example:
Fedora release 37 (Thirty Seven)
Or for CentOS:
CentOS Linux release 8.5.2111
Arch Linux
Arch Linux is a rolling release, so it doesn’t have version numbers in the traditional sense. However, you can check the /etc/arch-release file:
cat /etc/arch-release
This file is usually empty or just contains “Arch Linux”. For more details, use hostnamectl or uname -a.
OpenSUSE
On openSUSE, check the /etc/SuSE-release file (though it’s being phased out):
cat /etc/SuSE-release
Or use the zypper package manager:
zypper --version
Automating The Process With Scripts
If you manage multiple Linux servers, you might want to automate checking the OS version. Here’s a simple bash script that works on most distributions.
#!/bin/bash
# Script to detect OS version
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "OS: $PRETTY_NAME"
elif [ -f /etc/redhat-release ]; then
cat /etc/redhat-release
elif [ -f /etc/debian_version ]; then
echo "Debian version: $(cat /etc/debian_version)"
else
echo "Unknown OS"
fi
echo "Kernel: $(uname -r)"
Save this as check-os.sh, make it executable with chmod +x check-os.sh, and run it with ./check-os.sh. This script checks multiple files and falls back gracefully.
Troubleshooting Common Issues
Sometimes the commands above don’t work as expected. Here are some common problems and solutions.
Command Not Found Errors
If you get “command not found” for lsb_release or hostnamectl, it means the package isn’t installed. Install it using your package manager as shown earlier. For hostnamectl, it’s part of systemd, so if you’re using a non-systemd distribution like Alpine Linux, you’ll need a different method.
Empty Or Missing Files
If /etc/os-release is missing, check for /etc/lsb-release or /etc/*-release files. Some older distributions use different file names.
ls /etc/*release*
This lists all release files. You can then cat them to see their contents.
Container And Virtual Machine Differences
If you’re inside a Docker container or a virtual machine, the OS version shown might be the host’s kernel or a minimal base image. Use cat /etc/os-release inside the container to see the container’s OS, not the host’s.
Understanding The Output
Once you have the OS version, it’s important to understand what the numbers mean.
Version Numbering Schemes
Different distributions use different numbering:
- Ubuntu: Uses YY.MM format (e.g., 22.04 means April 2022). LTS versions are released every two years.
- Fedora: Uses sequential numbers (e.g., 37, 38). New versions come out every six months.
- Debian: Uses version numbers (e.g., 11, 12) with codenames (e.g., Bullseye, Bookworm).
- Arch Linux: Rolling release, no version numbers. You always have the latest packages.
Kernel Version Meaning
The kernel version format is major.minor.patch. For example, 5.15.0 means major version 5, minor version 15, and patch 0. The trailing -generic indicates it’s the generic kernel variant.
Practical Applications
Knowing your OS version helps in many real-world scenarios.
Software Installation
When installing software from source or third-party repositories, you often need to specify your distribution and version. For example, adding a PPA in Ubuntu requires knowing your codename (e.g., “jammy” for 22.04).
Security Updates
Different versions receive security updates for different durations. Ubuntu 20.04 LTS is supported until 2025, while 22.10 is only supported for nine months. Knowing your version helps you plan upgrades.
Compatibility Checks
Some applications only work on specific kernel versions or distribution releases. Checking your OS version before installing prevents compatibility issues.
Frequently Asked Questions
What is the fastest command to find the OS version in Linux?
The fastest command is hostnamectl if you have systemd. Otherwise, cat /etc/os-release works on almost all distributions.
How do I find the OS version without a terminal?
Open your desktop environment’s Settings or System Info panel. Look for “About” or “System Details” to see the OS name and version.
Can I find the OS version from a script?
Yes, you can parse /etc/os-release or use lsb_release -s -d in a script to get the version programmatically.
Why does my Linux system show a different kernel version than the OS version?
The kernel version is separate from the distribution version. You can update the kernel independently of the OS release, so they may not match.
How do I find the OS version on a headless server?
Use SSH to connect to the server, then run any of the terminal commands listed above, such as hostnamectl or cat /etc/os-release.
Conclusion
Now you know multiple ways to find the OS version in Linux. Whether you prefer the terminal or a graphical interface, there’s a method that works for your situation. The most reliable approach is checking /etc/os-release, as it’s standardized across modern distributions. For quick checks, hostnamectl is hard to beat. Remember to use this information to keep your system updated and compatible with the software you need. Practice these commands a few times, and you’ll be able to identify any Linux system’s version in seconds.