System
lsb_release
Print Linux Standard Base (LSB) distribution information.
distroversionreleaselsbsystem-info
Additional Notes
lsb_release prints detailed information about the Linux distribution, including the distributor ID, release version, codename, and description. It implements the Linux Standard Base (LSB) specification for reporting distribution metadata.
It is useful in scripts for detecting the current distribution and version to make platform-specific decisions. It reads data from the /etc/lsb-release file or the /usr/lib/os-release file.
Syntax
lsb_release [options]
Parameters
options: Flags that change howlsb_releasebehaves.target: Optional file, device, interface, user, service, or command target when the command supports one.
Common Options
-a,--all: Show all available information.-d,--description: Print the distribution description string.-r,--release: Print the release version number.-c,--codename: Print the distribution code name.-i,--id: Print the distributor ID.-s,--short: Short output format, one value per line.-h,--help: Show help message.
Examples
lsb_release -a
Show all distribution information.
lsb_release -d
Output: Description: Ubuntu 22.04.3 LTS
lsb_release -r -s
Output: 22.04 (short release number).
lsb_release -c -s
Output: jammy (short codename).
if [ "$(lsb_release -is)" = "Ubuntu" ]; then
echo "This is Ubuntu"
fi
Check the distribution in a script.
Practical Notes
- Not all distributions install
lsb_releaseby default. On Debian/Ubuntu, install it withapt install lsb-release. - On distributions without LSB tools, use
cat /etc/os-releaseorhostnamectlas alternatives. - The
-sflag is useful when capturing output in scripts for comparison.