How to Get Linux Distribution from Terminal
The 3 Ways + A note on Linux Standard Base
1 min readAug 29, 2022
The aim of this page📝 is to note the proper&quick localization of a linux distribution from terminal.
THE ‘/etc/os-release’ FILE
- The /etc/lsb-release file is a file that some (see above), but not all, Linux distributions put there
/etc/lsb-release
, isn't part of the standard. It's an extra thing that some distributions use, but not all.- It is the
/etc/os-release
file that is the standard - If you need a reliable way of detecting what distribution you’re running on, your best bet will be to read the /
etc/os-release
file. - If it’s not there you can try running the program called lsb_release.
- Print contents of
/etc/os-release
file
cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
THE ‘lsb_release’ PROGRAM
- lsb is an acronym for Linux Standard Base
The Linux Standard Base (LSB) was a joint project by several Linux distributions under the organizational structure of the Linux Foundation to standardize the software system structure
- Included: Redhat, SUSE, Ubuntu. Notably missing Debian distro.
- You can try
lsb_release -a
,
>>> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
THE ‘lsb-release’ FILE
- Print contents of
/etc/lsb-release
file
>>> cat /etc/lsb-release
root@f5617de5e362:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.6 LTS"