lsb_release: command not found

The minor version of RHEL server is defined by the /etc/redhat-release file and it belongs to redhat-release-server package. The lsb_release script points to /etc/redhat-release which gives the same output as ‘cat /etc/redhat-release’. Linux Standard Base (LSB) is basically a standard that multiple distributions sign up to. It specifies a Filesystem Hierarchy Standard (FHS), as well as various other components of a Linux system.

You might have noticed the Ubuntu usage of lsb_release to grab its OS version; the same can be done on CentOS, but first, lsb_release needs to be installed:

# yum install redhat-lsb-core

Now, we can run the same command that Ubuntu uses in order to get OS information:

$ lsb_release -s -d
"CentOS Linux release 7.5.1804 (Core) "

The same can be done on Debian, without having to install anything by default:

$ lsb_release -s -d
Debian GNU/Linux 9.5 (stretch)

If you encounter the below error while running the command lsb_release:

lsb_release: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install lsb-release
Ubuntu apt-get install lsb-release
Arch Linux pacman -S lsb-release
Kali Linux apt-get install lsb-release
CentOS yum install redhat-lsb-core
Fedora dnf install redhat-lsb-core
Raspbian apt-get install lsb-release

lsb_release Command Examples

1: Print all available information:

# lsb_release -a

2: Print a description (usually the full name) of the operating system:

# lsb_release -d

3: Print only the operating system name (ID), suppressing the field name:

# lsb_release -i -s

4: Print the release number and codename of the distribution, suppressing the field names:

# lsb_release -rcs
Related Post