Linux is a most popular open source OS used widely on many systems, servers and other machines like Raspberry Pi, etc. There are many variants out there in Linux which are known as distributions. The most common distributions are Ubuntu, Debian, SUSE, Mint, CentOS, Redhat, ArcLinux and many more.
It is better to know the version of your operating system when you update or install packages or installing security patches, etc.
Some distributions like Ubuntu, Debian shows the version of the OS when you login as a welcome message. But this can be disabled manually.
In this guide you going to learn how to identify your Linux OS and the version installed on your machine.
There are many methods available out there to check the OS and version.
This is the first command you want to try while identifying the installed OS and version. Most recent Linux distributions have this package installed which supports this command. LSB stands for Linux Standard Base which displays the basic information we need to know.
Output No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal
Every Linux distributions have a
os-release file inside the
etc directory. This file contains the detailed information of the operating system.
Output NAME="Ubuntu" VERSION="20.04.3 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.3 LTS" VERSION_ID="20.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=focal UBUNTU_CODENAME=focal
You can use the grep command to filter out the version line alone.
grep 'VERSION' /etc/os-release
hostnamectl is a tool to Control Linux System Hostname. This command outputs the hostname along with other system related details.
Now we can use grep to filter the output to display only the Operating system details.
hostnamectl | grep "Operating"
Output Operating System: Ubuntu 20.04.3 LTS
The proc directory has a version file which outputs the OS release information. This file doesn’t outputs the OS version, but with the information you can find the version of your distribution.
Output Linux version 5.11.0-1020-gcp ([email protected]) (gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #22~20.04.1-Ubuntu SMP Tue Sep 21 10:54:26 UTC 2021
Now you have learned how to identify the OS version of your Linux machine.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.
Leave a Reply