Linux:- Get Distro Name via lsb_release ( CentOS )

Background

Last evening, a family member asked me whether it is Ubuntu we are running on one of our Linux boxes.

I said I think it is CentOS.

But, I will confirm.

lsb_release

lsb_release to the rescue.

 

Error

Error – Command Not Found

Command – lsb_release

Syntax

lsb_release

Sample

lsb_release

Output

Output – Text
>sudo lsb_release
sudo: lsb_release: command not found
>
Output – Image

 

 

Installation

Where can I get lsb_release?

There are a couple of pathways we can explore to determine which registered repo and package provides a command.

Options

  1. yum
    • what-provides
  2. dnf
    • dnf provides

Command

yum

yum – what-provides
Outline

We can use yum’s whatprovides option to inquire as to which repository and package provides a file or library.

Syntax
yum whatprovides [file]
Sample
yum whatprovides lsb_release -y
Output – Text

>yum whatprovides lsb_release -y
Last metadata expiration check: 7:20:55 ago on Mon 19 Sep 2022 09:37:09 PM PDT.
redhat-lsb-core-4.1-47.el8.i686 : LSB Core module support
Repo        : appstream
Matched from:
Filename    : /usr/bin/lsb_release

redhat-lsb-core-4.1-47.el8.x86_64 : LSB Core module support
Repo        : @System
Matched from:
Filename    : /usr/bin/lsb_release

redhat-lsb-core-4.1-47.el8.x86_64 : LSB Core module support
Repo        : appstream
Matched from:
Filename    : /usr/bin/lsb_release

>


Output – Image

 

dnf

dnf provides
Outline

From https://dnf.readthedocs.io/en/latest/command_ref.html ( Link )

Lists all modular packages matching <package-name-spec> from all modules (including disabled), along with the modules and streams they belong to.
Syntax

dnf provides lsb_release

Sample

dnf provides lsb_release

Output – Text
>dnf provides lsb_release
Last metadata expiration check: 8:28:18 ago on Mon 19 Sep 2022 09:37:09 PM PDT.
redhat-lsb-core-4.1-47.el8.i686 : LSB Core module support
Repo        : appstream
Matched from:
Filename    : /usr/bin/lsb_release

redhat-lsb-core-4.1-47.el8.x86_64 : LSB Core module support
Repo        : appstream
Matched from:
Filename    : /usr/bin/lsb_release

>

Output – Image

Explanation
  1. Repo
    • appstream
  2. Package
    • Package Name:-
      • redhat-lsb-core
    • Package Description
      • LSB Core module support
    • Version:-
      • redhat-lsb-core-4.1-47.el8.i686
      • redhat-lsb-core-4.1-47.el8.x86_64
    • Filename:-
      • /usr/bin/lsb_release

Install lsb-release

We can use yum or dnf to install the package.

Options

  1. yum
    • yum install
  2. dnf
    • dnf install

Command

yum

yum – install
Outline

To install the package, we will simply issue yum install.

Syntax

yum install <package>

Sample

sudo yum install redhat-lsb-core -y

Output – Text

>sudo yum install redhat-lsb-core -y
[sudo] password for dadeniji:
Last metadata expiration check: 0:42:33 ago on Mon 19 Sep 2022 08:58:04 PM PDT.
Dependencies resolved.
=============================================================================================================================================================================================================================================
 Package                                                             Architecture                                    Version                                                        Repository                                          Size
=============================================================================================================================================================================================================================================
Installing:
 redhat-lsb-core                                                     x86_64                                          4.1-47.el8                                                     appstream                                           46 k
Installing dependencies:
 esmtp                                                               x86_64                                          1.2-15.el8                                                     epel                                                57 k
 libesmtp                                                            x86_64                                          1.0.6-18.el8                                                   epel                                                70 k
 liblockfile                                                         x86_64                                          1.14-2.el8                                                     appstream                                           32 k
 m4                                                                  x86_64                                          1.4.18-7.el8                                                   baseos                                             223 k
 mailx                                                               x86_64                                          12.5-29.el8                                                    baseos                                             257 k
 ncurses-compat-libs                                                 x86_64                                          6.1-9.20180224.el8                                             baseos                                             328 k
 patch                                                               x86_64                                          2.7.6-11.el8                                                   baseos                                             138 k
 redhat-lsb-submod-security                                          x86_64                                          4.1-47.el8                                                     appstream                                           22 k
 spax                                                                x86_64                                          1.5.3-13.el8                                                   baseos                                             217 k

Transaction Summary
=============================================================================================================================================================================================================================================
Install  10 Packages

Total download size: 1.4 M
Installed size: 2.9 M
Downloading Packages:
(1/10): redhat-lsb-submod-security-4.1-47.el8.x86_64.rpm                                                                                                                                                      75 kB/s |  22 kB     00:00
(2/10): liblockfile-1.14-2.el8.x86_64.rpm                                                                                                                                                                    105 kB/s |  32 kB     00:00
(3/10): redhat-lsb-core-4.1-47.el8.x86_64.rpm                                                                                                                                                                146 kB/s |  46 kB     00:00
(4/10): m4-1.4.18-7.el8.x86_64.rpm                                                                                                                                                                           272 kB/s | 223 kB     00:00
(5/10): mailx-12.5-29.el8.x86_64.rpm                                                                                                                                                                         286 kB/s | 257 kB     00:00
(6/10): ncurses-compat-libs-6.1-9.20180224.el8.x86_64.rpm                                                                                                                                                    322 kB/s | 328 kB     00:01
(7/10): patch-2.7.6-11.el8.x86_64.rpm                                                                                                                                                                        427 kB/s | 138 kB     00:00
(8/10): spax-1.5.3-13.el8.x86_64.rpm                                                                                                                                                                         452 kB/s | 217 kB     00:00
(9/10): libesmtp-1.0.6-18.el8.x86_64.rpm                                                                                                                                                                      93 kB/s |  70 kB     00:00
(10/10): esmtp-1.2-15.el8.x86_64.rpm                                                                                                                                                                          67 kB/s |  57 kB     00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                        346 kB/s | 1.4 MB     00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                     1/1
  Installing       : libesmtp-1.0.6-18.el8.x86_64                                                                                                                                                                                       1/10
  Installing       : spax-1.5.3-13.el8.x86_64                                                                                                                                                                                           2/10
  Running scriptlet: spax-1.5.3-13.el8.x86_64                                                                                                                                                                                           2/10
  Installing       : patch-2.7.6-11.el8.x86_64                                                                                                                                                                                          3/10
  Installing       : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                                                                                                                                                      4/10
  Installing       : mailx-12.5-29.el8.x86_64                                                                                                                                                                                           5/10
  Installing       : m4-1.4.18-7.el8.x86_64                                                                                                                                                                                             6/10
  Running scriptlet: m4-1.4.18-7.el8.x86_64                                                                                                                                                                                             6/10
  Installing       : redhat-lsb-submod-security-4.1-47.el8.x86_64                                                                                                                                                                       7/10
  Installing       : liblockfile-1.14-2.el8.x86_64                                                                                                                                                                                      8/10
  Running scriptlet: liblockfile-1.14-2.el8.x86_64                                                                                                                                                                                      8/10
  Installing       : esmtp-1.2-15.el8.x86_64                                                                                                                                                                                            9/10
  Running scriptlet: esmtp-1.2-15.el8.x86_64                                                                                                                                                                                            9/10
  Installing       : redhat-lsb-core-4.1-47.el8.x86_64                                                                                                                                                                                 10/10
  Running scriptlet: redhat-lsb-core-4.1-47.el8.x86_64                                                                                                                                                                                 10/10
  Verifying        : liblockfile-1.14-2.el8.x86_64                                                                                                                                                                                      1/10
  Verifying        : redhat-lsb-core-4.1-47.el8.x86_64                                                                                                                                                                                  2/10
  Verifying        : redhat-lsb-submod-security-4.1-47.el8.x86_64                                                                                                                                                                       3/10
  Verifying        : m4-1.4.18-7.el8.x86_64                                                                                                                                                                                             4/10
  Verifying        : mailx-12.5-29.el8.x86_64                                                                                                                                                                                           5/10
  Verifying        : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                                                                                                                                                      6/10
  Verifying        : patch-2.7.6-11.el8.x86_64                                                                                                                                                                                          7/10
  Verifying        : spax-1.5.3-13.el8.x86_64                                                                                                                                                                                           8/10
  Verifying        : esmtp-1.2-15.el8.x86_64                                                                                                                                                                                            9/10
  Verifying        : libesmtp-1.0.6-18.el8.x86_64                                                                                                                                                                                      10/10
Installed products updated.

Installed:
  esmtp-1.2-15.el8.x86_64            libesmtp-1.0.6-18.el8.x86_64                  liblockfile-1.14-2.el8.x86_64  m4-1.4.18-7.el8.x86_64  mailx-12.5-29.el8.x86_64  ncurses-compat-libs-6.1-9.20180224.el8.x86_64  patch-2.7.6-11.el8.x86_64
  redhat-lsb-core-4.1-47.el8.x86_64  redhat-lsb-submod-security-4.1-47.el8.x86_64  spax-1.5.3-13.el8.x86_64

Complete!
>

Output – Image

dnf

dnf – install
Outline

In lieu of yum install, we can use “dnf install” to install the package.

Syntax

dnf install <package>

Sample

sudo dnf install redhat-lsb-core -y

Output – Text

>sudo dnf install redhat-lsb-core -y
[sudo] password for dadeniji:
Last metadata expiration check: 1:01:39 ago on Tue 20 Sep 2022 04:36:46 AM PDT.
Dependencies resolved.
============================================================================================================
 Package                             Architecture    Version                       Repository          Size
============================================================================================================
Installing:
 redhat-lsb-core                     x86_64          4.1-47.el8                    appstream           46 k
Installing dependencies:
 esmtp                               x86_64          1.2-15.el8                    epel                57 k
 libesmtp                            x86_64          1.0.6-18.el8                  epel                70 k
 liblockfile                         x86_64          1.14-2.el8                    appstream           32 k
 m4                                  x86_64          1.4.18-7.el8                  baseos             223 k
 mailx                               x86_64          12.5-29.el8                   baseos             257 k
 ncurses-compat-libs                 x86_64          6.1-9.20180224.el8            baseos             328 k
 patch                               x86_64          2.7.6-11.el8                  baseos             138 k
 redhat-lsb-submod-security          x86_64          4.1-47.el8                    appstream           22 k
 spax                                x86_64          1.5.3-13.el8                  baseos             217 k

Transaction Summary
============================================================================================================
Install  10 Packages

Total download size: 1.4 M
Installed size: 2.9 M
Downloading Packages:
(1/10): liblockfile-1.14-2.el8.x86_64.rpm                                    23 kB/s |  32 kB     00:01
(2/10): redhat-lsb-submod-security-4.1-47.el8.x86_64.rpm                     16 kB/s |  22 kB     00:01
(3/10): redhat-lsb-core-4.1-47.el8.x86_64.rpm                                30 kB/s |  46 kB     00:01
(4/10): m4-1.4.18-7.el8.x86_64.rpm                                          509 kB/s | 223 kB     00:00
(5/10): mailx-12.5-29.el8.x86_64.rpm                                        481 kB/s | 257 kB     00:00
(6/10): patch-2.7.6-11.el8.x86_64.rpm                                       674 kB/s | 138 kB     00:00
(7/10): spax-1.5.3-13.el8.x86_64.rpm                                        571 kB/s | 217 kB     00:00
(8/10): ncurses-compat-libs-6.1-9.20180224.el8.x86_64.rpm                   395 kB/s | 328 kB     00:00
(9/10): esmtp-1.2-15.el8.x86_64.rpm                                          94 kB/s |  57 kB     00:00
(10/10): libesmtp-1.0.6-18.el8.x86_64.rpm                                   162 kB/s |  70 kB     00:00
------------------------------------------------------------------------------------------------------------
Total                                                                       284 kB/s | 1.4 MB     00:04
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                    1/1
  Installing       : libesmtp-1.0.6-18.el8.x86_64                                                      1/10
  Installing       : spax-1.5.3-13.el8.x86_64                                                          2/10
  Running scriptlet: spax-1.5.3-13.el8.x86_64                                                          2/10
  Installing       : patch-2.7.6-11.el8.x86_64                                                         3/10
  Installing       : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                     4/10
  Installing       : mailx-12.5-29.el8.x86_64                                                          5/10
  Installing       : m4-1.4.18-7.el8.x86_64                                                            6/10
  Running scriptlet: m4-1.4.18-7.el8.x86_64                                                            6/10
  Installing       : redhat-lsb-submod-security-4.1-47.el8.x86_64                                      7/10
  Installing       : liblockfile-1.14-2.el8.x86_64                                                     8/10
  Running scriptlet: liblockfile-1.14-2.el8.x86_64                                                     8/10
  Installing       : esmtp-1.2-15.el8.x86_64                                                           9/10
  Running scriptlet: esmtp-1.2-15.el8.x86_64                                                           9/10
  Installing       : redhat-lsb-core-4.1-47.el8.x86_64                                                10/10
  Running scriptlet: redhat-lsb-core-4.1-47.el8.x86_64                                                10/10
  Verifying        : liblockfile-1.14-2.el8.x86_64                                                     1/10
  Verifying        : redhat-lsb-core-4.1-47.el8.x86_64                                                 2/10
  Verifying        : redhat-lsb-submod-security-4.1-47.el8.x86_64                                      3/10
  Verifying        : m4-1.4.18-7.el8.x86_64                                                            4/10
  Verifying        : mailx-12.5-29.el8.x86_64                                                          5/10
  Verifying        : ncurses-compat-libs-6.1-9.20180224.el8.x86_64                                     6/10
  Verifying        : patch-2.7.6-11.el8.x86_64                                                         7/10
  Verifying        : spax-1.5.3-13.el8.x86_64                                                          8/10
  Verifying        : esmtp-1.2-15.el8.x86_64                                                           9/10
  Verifying        : libesmtp-1.0.6-18.el8.x86_64                                                     10/10
Installed products updated.

Installed:
  esmtp-1.2-15.el8.x86_64   libesmtp-1.0.6-18.el8.x86_64      liblockfile-1.14-2.el8.x86_64
  m4-1.4.18-7.el8.x86_64    mailx-12.5-29.el8.x86_64          ncurses-compat-libs-6.1-9.20180224.el8.x86_64
  patch-2.7.6-11.el8.x86_64 redhat-lsb-core-4.1-47.el8.x86_64 redhat-lsb-submod-security-4.1-47.el8.x86_64
  spax-1.5.3-13.el8.x86_64

Complete!
>


Output – Image

Run lsb-release

Let us invoke lsb-release.

Options

  1. Base
    • lsb-release
  2. Description ( –description )
    • lsb-release -d
  3. Distributor’s String ID ( –id )
    • lsb-release -i
  4. All ( –all )
    • lsb-release -a

Syntax

lsb-release

Sample – Base


lsb-release

Output

Output – Text
>lsb_release
LSB Version: :core-4.1-amd64:core-4.1-noarch
>
Output – Image

 

Sample – Description


lsb-release -d

Output

Output – Text
>lsb_release -d
Description: CentOS Stream release 8
>
Output – Image

Sample – Distributor


lsb-release -i

Output

Output – Text

>lsb_release -i
Distributor ID: CentOSStream
>

Output – Image

Sample – All


lsb-release -a

Output

Output – Text

>lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOSStream
Description:    CentOS Stream release 8
Release:        8
Codename:       n/a
>

Output – Image

 

Referenced Work

  1. The Geek Diary
    • “lsb_release: command not found” – Fix in CentOS/RHEL
      Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s