How to fix “lsb_release command not found” in CentOS/RHEL?

The lsb_release is a Linux command that is used to display the LSB information of a specific Linux distribution. This information includes the Linux version, distributor Id, codenames, etc. This command is part of a package called LSB core.

While finding the version number on CentOS or RHEL you may get an error that says “lsb_release command not found”. In this article, we will discuss how you can fix this issue on a CentOS or RHEL system.

Why you are getting the “lsb_release command not found” error

When you try to find the version and execute the lsb_release command on your system.

lsb_release -v

It shows the output as given in the image below.

You are getting this because the package providing this command is by default not installed on CentOS or RHEL. So first you need to find the package name that provides this command and then install this command to use the lsb_release command.

How to find the package name that provides the lsb_release command on CentOS/ RHEL

You could use the following command to see the lsb_release command comes in which package.

On CentOS 7/ RHEL use –

yum whatprovides lsb_release

If you are using CentOS 8/ RHEL then use –

dnf whatprovides lsb_release

The output will look like this –

Here you can see the package name i.e. redhat-lsb-core in which the lsb_release command exists.

Installing redhat-lsb-core package on CentOS /RHEL

To install this package to use the lsb_release command on your system use the following command on your system.

dnf install redhat-lsb-core

This will ask you for confirmation, press y and then enter to proceed.

Once it gets successfully installed try running the lsb_release command.

lsb_release -a

Now you will see the output of this command.

You can see the list of options by running the given command.

man lsb_release

Conclusion

You will now able to use this command on CentOS /RHEL on other distribution this package may available with some other name so find the correct package and then install it.

Now if you have a query then write us in the comments below.

Leave a Comment