Site icon NetworkHunt

How to check OS version in Linux

How to check OS version in Linux

To check the OS version in Linux can be used for troubleshooting, installing compatible software, or ensuring system compatibility. There are several ways to check the OS version in Linux. In this guide, we’ll cover multiple methods, from using simple command-line tools like `lsb_release` and `uname` to accessing system information through graphical interfaces. Each method provides detailed insights into the Linux version.

Table of Contents

  1. Using os-release file
  2. Using lsb_release command
  3. Using the hostnamectl command
  4. Using the uname command
  5. Using GUI

Method-1: Using os-release file

The os-release file in the /etc directory is a text file that contains information about the operating system (OS) installed on a Linux-based system. It provides essential details such as the OS name, version, and other system-related identifiers, making it useful for scripts or applications that need to detect or configure the system based on its OS.

Key fields found in the os-release file are-

To view to contents of the os-release file use the command below-

$> cat /etc/os-release

To filter out only the Version or the Name and Version of the Operating System from the os-release file use the command below-

$> grep '^VERSION' /etc/os-release
$> grep -E '^(VERSION|NAME)=' /etc/os-release

Method-2: Using lsb_release command

The LSB (Linux Standard Base) is a set of standards that aim to increase compatibility among different Linux distributions. It defines a common set of specifications that Linux distributions should follow to ensure that software developed for one distribution can run on others without modification. The LSB specifies standards for core system libraries, the file system hierarchy, and various command-line utilities.

The LSB defines a tool, lsb_release, which provides a standard way to query the version and other details of a Linux distribution. This tool reads from /etc/os-release or other related configuration files to fetch distribution-specific details. It is commonly used to retrieve information about the OS in a consistent format across different Linux distributions.

Options used with the lsb_release command are-

-a : This option will output detailed information about the distribution, including the distributor ID, description, release version, and codename.

$> lsb_release -a

-d :  This option will output only the name of the distribution.

$> lsb_release -d

-r :  This option will output only the version number of the OS.

$> lsb_release -r

-c :  This option will output only the codename of the distribution.

$> lsb_release -c

-i : This option will output only the name of the distributor.

$> lsb_release -i

Method-3: Using the hostnamectl command

The hostnamectl command is a utility in Linux used to query and change the system’s hostname and related settings. It is part of the systemd suite of tools, which is widely used on modern Linux distributions. While its primary purpose is to manage the system’s hostname, hostnamectl can also provide valuable system information, such as the operating system version, kernel version, architecture, and more.

Key Information provided by hostnamectl are-

To view only the os-version using hostnamectl command use-

$> hostnamectl | grep "Operating System"

Method-4: Using the uname command

The uname (short for “Unix name”) command is used to display system information. It provides details about the kernel, system architecture, and other important information. While uname does not provide the complete OS version (like lsb_release or hostnamectl), it can be useful for gathering kernel and system architecture details.

Options used with the uname command are-

-r : Displays the kernel version.

$> uname -r

-a : Displays all available system information, including the kernel version, architecture, and system name.

$> uname -a

-m : Displays the system architecture.

$> uname -m

-s : Displays the kernel name.

$> uname -s

Method-5: Using GUI

This method may vary across different Linux distributions, as each distro has its own GUI and settings layout. Here, we will demonstrate the process for Ubuntu Linux.

Step 1: Open the Settings application
Step 2: Access the About section
Step 3: View the OS version

In the About section, you will see information about your system, including:

Exit mobile version