What is the Linux lsb_release command?




What is the Linux lsb_release command?

The lsb_release command is a Linux command that displays certain LSB (Linux Standard Base) and distribution-specific information about the Linux distribution running on a system. The command is used to determine the specific version and name of the Linux distribution that is being used.

Here's an example of how to use the lsb_release command:

lsb_release -a

This command will display all available LSB and distribution-specific information about the Linux distribution, including the distribution ID, description, release number, and codename.

The output of the lsb_release command can be useful in shell scripts or in other situations where you need to programmatically determine the version and name of the Linux distribution.

The lsb_release command is a standard Linux command that is part of the LSB (Linux Standard Base) specification. The LSB specification is a set of standards designed to increase compatibility between different Linux distributions, and the lsb_release command is one of the tools provided to help achieve this goal.

The lsb_release command provides the following options:-

-a: displays all available information about the Linux distribution.

-i: displays the distribution ID (e.g., "Ubuntu", "Debian", "Red Hat Enterprise Linux").

-d: displays the distribution description.

-r: displays the release number.

-c: displays the code name of the distribution.

-s: displays only the specified information without any additional formatting or descriptive text.

The output of the lsb_release command varies depending on the Linux distribution being used. For example, here's the output of lsb_release -a on an Ubuntu system:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:        20.04
Codename:       focal

And here's the output of the same command on a CentOS system:

LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 8.5.2111
Release:        8.5.2111
Codename:       n/a

Overall, the lsb_release command is a useful tool for identifying information about the Linux distribution running on a system, which can be particularly helpful when troubleshooting issues or developing scripts that need to work across different Linux distributions.

How to use the lsb release command in Linux to check the OS version

The lsb_release command is a standard Linux command used to retrieve the distribution-specific information about the system, including the release version. Here's how to use it to check the OS version:-

Open a terminal window.

Type the following command:

lsb_release -a

Press Enter.

The command will output several lines of information, including the Description field, which will give you the name of the Linux distribution and its version number. For example, the output might look like this:

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal

In this example, the OS version is "20.04.1 LTS".

That's it! The lsb_release command is a handy way to quickly check the version of your Linux distribution.

The codename for a Linux release

The command line option -c is the one for you if all you need to know is the Codename of your Linux distribution. You really enjoy it because most seasoned users merely use the codenames and infrequently give the release number, but many beginners have an extremely difficult time figuring out their Ubuntu codename.

ubuntu$ lsb_release -c  
Codename: feisty