How To Check Linux Os Version – Using Lsb Release Command Output

Linux OS version is shown by `cat /etc/*release` or `hostnamectl` to see the operating system and kernel. If you’re wondering how to check linux os version quickly, you’ve come to the right place. Knowing your Linux version is essential for troubleshooting, installing software, or ensuring compatibility. This guide covers every major method, from simple commands to GUI tools, so you can get the info you need fast.

Whether you’re a beginner or a seasoned sysadmin, checking your OS version is a fundamental skill. Different distributions use different files and commands, but don’t worry—I’ll walk you through each one. By the end, you’ll be able to identify your Linux version in seconds.

How To Check Linux Os Version

Let’s start with the most reliable methods. These commands work on almost any Linux distribution, including Ubuntu, Debian, Fedora, CentOS, and Arch Linux. The key is knowing where to look.

Using The /Etc/Os-Release File

The `/etc/os-release` file is a standard across modern Linux distributions. It contains detailed information about the operating system. To view it, open your terminal and run:

cat /etc/os-release

This will output something like:

NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
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"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

The `PRETTY_NAME` field gives you the human-readable version. This method works on almost all distributions that follow the freedesktop.org standard.

Using The /Etc/Lsb-Release File

Some older distributions use `/etc/lsb-release`. This file is specific to LSB (Linux Standard Base) compliant systems. Run:

cat /etc/lsb-release

You’ll see output like:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

If the file doesn’t exist, don’t worry—it’s not present on all systems. The `/etc/os-release` file is more universal.

Using The Hostnamectl Command

The `hostnamectl` command is part of systemd and provides system information, including the OS version. It’s simple and effective:

hostnamectl

Output example:

   Static hostname: my-server
         Icon name: computer-vm
           Chassis: vm
        Machine ID: abc123def456
           Boot ID: ghi789jkl012
    Virtualization: kvm
  Operating System: Ubuntu 20.04.6 LTS
            Kernel: Linux 5.4.0-150-generic
      Architecture: x86-64

Notice it shows both the operating system and kernel version. This is one of the fastest ways to get a comprehensive overview.

Using The Lsb_Release Command

If the `lsb_release` command is installed, it’s a dedicated tool for version info. Try:

lsb_release -a

Output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal

If you get “No LSB modules are available,” that’s normal. The important info is still shown. You can also use `lsb_release -d` for just the description.

Checking The Kernel Version

Sometimes you need the kernel version, not just the OS release. Use:

uname -r

This returns something like `5.4.0-150-generic`. For full kernel details, use `uname -a`:

uname -a

Output: `Linux my-server 5.4.0-150-generic #167-Ubuntu SMP Wed May 24 00:51:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux`

This shows the kernel release, machine hardware, and more. It’s useful for debugging driver issues.

Distribution-Specific Methods

Different Linux families have their own quirks. Here’s how to check the version on popular distributions.

Debian And Ubuntu

On Debian-based systems, you can also check `/etc/debian_version`:

cat /etc/debian_version

For Ubuntu, the file `/etc/ubuntu-release` might exist, but `/etc/os-release` is more reliable. Another handy command is:

cat /etc/issue

This shows a brief welcome message that includes the version.

Red Hat, CentOS, And Fedora

On Red Hat-based systems, check `/etc/redhat-release`:

cat /etc/redhat-release

For CentOS, you might see `CentOS Linux release 7.9.2009 (Core)`. Fedora users can use the same file. Alternatively, `rpm -q centos-release` or `rpm -q fedora-release` works.

Arch Linux

Arch Linux is a rolling release, so there’s no static version number. Instead, check the kernel and package versions:

uname -r
pacman -Q linux

You can also look at `/etc/arch-release` which is usually empty but confirms it’s Arch.

OpenSUSE

On openSUSE, use:

cat /etc/os-release

Or the SUSE-specific file:

cat /etc/SuSE-release

This file is deprecated but still present on older systems.

Using Graphical User Interface (Gui) Methods

If you prefer a graphical interface, most desktop environments have a “Settings” or “About” section.

Gnome Desktop

On GNOME, go to Settings > About. You’ll see the OS name, version, and kernel. This is found in the “Device Name” section.

Kde Plasma

On KDE, open System Settings > About This System. It shows distribution, kernel, and architecture.

Xfce

On Xfce, click the Applications menu > Settings > About Xfce. This shows the Xfce version, but for OS info, you might need to check via terminal.

Other Desktop Environments

Most environments have a similar “About” dialog. Look for “System Info” or “Details” in the settings menu.

Checking The Os Version Remotely

Need to check a remote server? Use SSH to connect and then run the commands above. For example:

ssh user@remote-server "cat /etc/os-release"

You can also use `hostnamectl` remotely if you have sudo access. For multiple servers, consider writing a script.

Using Ansible Or Other Tools

If you manage many machines, tools like Ansible can gather facts:

ansible all -m setup -a "filter=ansible_distribution*"

This returns distribution name, version, and more for all hosts.

Understanding The Output

Let’s break down what you see. The OS version usually includes a major and minor number, like “20.04” for Ubuntu. The codename (e.g., “Focal Fossa”) helps identify the release cycle. The kernel version follows a different numbering scheme, like “5.4.0-150-generic”.

Knowing these details helps with package compatibility. For example, some software requires a minimum kernel version or specific OS release.

Common Issues And Troubleshooting

Sometimes commands don’t work as expected. Here are solutions to frequent problems.

File Not Found Errors

If `/etc/os-release` doesn’t exist, try `/etc/*release` to list all release files:

cat /etc/*release

This wildcard catches any release file. If nothing shows, your system might be very old or custom-built.

Command Not Found

If `lsb_release` is missing, install it with your package manager:

sudo apt install lsb-release  # Debian/Ubuntu
sudo yum install redhat-lsb    # RHEL/CentOS

Or just rely on the file methods.

Permission Denied

All the commands mentioned work without sudo. If you get permission errors, you might be in a restricted environment. Use `cat` with `sudo` if necessary, but it’s rare.

Automating Os Version Checks

For scripting, use the `source` command to read `/etc/os-release` variables:

source /etc/os-release
echo $PRETTY_NAME

This lets you use variables like `$VERSION_ID` in scripts. Another approach is parsing `hostnamectl` with `grep`:

hostnamectl | grep "Operating System"

Example Script

Here’s a simple bash script to check and display the OS version:

#!/bin/bash
if [ -f /etc/os-release ]; then
    . /etc/os-release
    echo "OS: $PRETTY_NAME"
else
    echo "Cannot determine OS version"
fi

Save it as `check_os.sh`, make it executable with `chmod +x check_os.sh`, and run it.

Comparing Different Methods

Each method has its pros and cons. Here’s a quick comparison:

  • /etc/os-release: Most universal, detailed, but might not exist on very old systems.
  • hostnamectl: Quick, shows kernel too, requires systemd.
  • lsb_release: Dedicated tool, but not always installed.
  • uname: Only kernel info, not OS version.
  • GUI: Easy for beginners, but limited to desktop environments.

For most users, `cat /etc/os-release` or `hostnamectl` is enough.

Why Knowing Your Os Version Matters

Software dependencies often require a specific OS version. For example, Docker might need Ubuntu 18.04 or later. Security patches are also version-specific. When you ask for help online, people will ask for your OS version first.

Additionally, some commands behave differently across versions. Knowing your exact version helps you follow the right tutorials.

Best Practices For Version Checking

Always verify using multiple methods if you’re unsure. For critical systems, document the version. Keep your system updated to avoid compatibility issues.

If you’re writing scripts, use the `source` method for reliability. Avoid parsing `lsb_release -a` output with `awk` because the format can vary.

Frequently Asked Questions (Faq)

How Do I Check The Linux OS Version Without A Command Line?

Use the graphical “Settings” or “About” menu in your desktop environment. Look for “Details” or “System Information.”

What’s The Difference Between OS Version And Kernel Version?

The OS version refers to the distribution release (e.g., Ubuntu 20.04), while the kernel version is the core of the Linux system (e.g., 5.4.0). They are independent.

Can I Check The OS Version On A Live USB?

Yes, the same commands work on live USB sessions. Boot into the live environment and open a terminal.

Why Does `Lsb_release -A` Show “No LSB Modules Are Available”?

This is normal. It just means the LSB module package isn’t installed. The distribution info is still displayed.

How Do I Check The OS Version On A Headless Server?

SSH into the server and run `cat /etc/os-release` or `hostnamectl`. No GUI needed.

Now you have all the tools to check your Linux OS version. Whether you use the terminal or GUI, these methods are reliable and fast. Remember the key commands: `cat /etc/os-release`, `hostnamectl`, and `uname -r`. Bookmark this guide for quick reference.