How to Check OS version in Linux with lsb_release command

In this tutorial we are going to look at the list of available commands to Check OS version in Linux.

There are various reasons why you might want to find which Linux distribution you are using or the OS version of your Linux system. To know the version of Linux installed on your computer, there are many options. One of the options is the lsb_release command.

Install lsb_release command in Linux

The lsb_release command not installed as part of the default installation in some Linux distributions. So, it needs to be installed first.

To instal lsb_release command on RedHat, CentOS and Fedora, Type:

sudo yum install redhat-lsb-core

On Debian, Ubuntu, Linux Mint, Type:

sudo apt-get install lsb-release

Find Linux Version with lsb_release command

With the package installed, we will use the lsb_release command to check Linux version. To determine which version of Linux you are running, Open the command line and execute:

lsb_release -a

The lsb_release command with the -a option show version information for the Linux OS you’re running. For example, Following is the output in my Linux server:

LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core

As output shows, I am using CentOS Linux version 7.

Command Options

-i, --id Display the ID/Name of the Linux Distribution (Example: Ubuntu, CentOS, RedHat..).
-d, --description Display a description of the currently installed operating system, including OS version.
-r, --release Show the OS version number of the currently installed Linux distribution.
-c, --codename Show the code name of the currently installed distribution.
-a, --all Show all of the above information.

More commands to Check Linux Version

There are more that one way to find what Linux OS version you are running. Most Linux distributions have /etc/os-release file which contains all the information you need to know.

To view the content of the /etc/os-release file, Execute following command:

cat /etc/os-release

You should get output similar to the following:

VERSION="16.04 LTS (Xenial Xerus)"
PRETTY_NAME="Ubuntu 16.04 LTS"

Another method is to display the contents of the /etc/redhat-release file which should exist on any Red Hat based distribution, such as Red Hat Enterprise Linux , CentOS, Fedora and Oracle Linux.

cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

As you can see it is very easy to check the OS version in Linux and there is more than one way to do it.