There are many commands in Linux to get the same information and one such command is the lsb_release, which is used to get the Linux distribution-related information such as OS name, code name, release information.
[ You might also like: How to Find Top Running Processes by Memory Usage ]
In some Linux distributions, the lsb_release command will be available to use and in some distributions, you have to install it, as this command is part of the LSB-core package.
Check Linux Distribution Information
To check if the lsb_release command is installed run the following command.
$ which lsb_release /usr/bin/lsb_release
In some distributions like Ubuntu, this command is already available to use but you will get the following error when you try to use some flags.
$ lsb_release -v No LSB modules are available.
Install lsb-core in Linux Distributions
To fix this you need to install the lsb-core package. Depending upon the distribution you are using run the following commands to install the lsb-core package.
------- On Debian/Ubuntu ------- $ sudo apt-get update $ sudo apt-get install lsb-core ------- On Arch/Manjaro ------- $ pacman -Syu lsb-release ------- On RHEL/CentOS ------- $ sudo yum update $ sudo yum install redhat-lsb-core ------- On Fedora ------- $ sudo dnf update $ sudo dnf install redhat-lsb-core ------- On SUSE ------- $ sudo zypper update $ sudo zypper install lsb-core
Get Linux Distribution Information
Once installed, try to run the lsb_release command again.
$ lsb_release -v
To get the list of available options you can refer to the man page or
$ man lsb_release $ lsb_release -h
To check the description, about your distribution use the
$ lsb_release -d
To check the version information using the
$ lsb_release -r Release: 20.04
Every distribution comes with a code name. For example, Ubuntu 20.04 comes with the name “Focal Fossa”. To get the name use the ‘-c’ flag.
$ lsb_release -c Codename: focal
You can get all the information by using the
$ lsb_release -a
If you look at the output so far it is in key-value pair. You can just display the value alone by using the
$ lsb_release -i Distributor ID: Ubuntu $ lsb_release -is Ubuntu
That’s it for this article. The lsb_release is a simple command to get information about your distribution.