Categories
Linux

How to Check Linux Version

All the commands you need to know more about your Linux computer

Linux is one of the most favorite Operating System among Open Source enthusiasts. It comes in multiple flavors and all of them are unique in their own way.

Advertisements

Saying that, ‘I use a Linux system’ is a very generic statement. In that case, I have to ask you, ‘Which distribution of Linux are you using? Is it Suse, Ubuntu, CentOS, Fedora, Kali, Red Hat, Debian, OpenSuse?’ These are all the common Linux distribution names that are popular and most commonly used.

Learning about your current Linux version can be interesting and at the same time, useful. The users who work with the command line more frequently and are involved with the system programming, they need to know the version of their systems to customize the security features and make modifications with the software packages installed if necessary.

Let us walk through this simple tutorial to learn about the command to list the versions of the Linux system.


Using lsb_release command

Advertisements

LSB stands for ‘Linux Standard Base’. This simple command-line utility can be used to check the version of your Linux system directly via the command line. You can use this command with two options -a and -d.

Using the lsb_release command with the -a option will display detailed information about the installed Linux version.

Example:

lsb_release -a

Output:

No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.5 LTS Release: 18.04 Codename: bionic gaurav@ubuntu:~$

From the above example you can see that I am running Ubuntu 18.04.5 LTS version.

Advertisements

You can also use the lsb_release command with the option -d. This will display only the ‘Description Line’.

Example:

lsb_release -d

Output:

Description: Ubuntu 18.04.5 LTS

Using /etc/os-release file

The /etc/os-release file contains operating system identification data. You can access this file to learn about the Linux distribution which you are running. Use the cat command to display the contents of this file.

Example:

cat /etc/os-release
Advertisements

Output:

NAME="Ubuntu" VERSION="18.04.5 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.5 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 gaurav@ubuntu:~$

Using /etc/issue file

The /etc/issue file is a standard file found on all the Linux distributions. This issue file may contain certain escape codes to display the system name, date and time etc.

The system identification text contained in this file is displayed before the user logs in to the system. Information about the Linux version is also present in this file and hence /etc/issue file is important to us.

Example:

cat /etc/issue

Output:

Ubuntu 18.04.5 LTS \n \l

Using uname command

Advertisements

The uname command is used to display the basic information about the operating system. This command can be used with various options to display the specific information you want to display.

We will be using the uname command with the option -r to display the Linux version.

Example:

uname -r

Output:

4.15.0-112-generic

Using hostnamectl command

Running hostnamectl command checks the current hostnames as well as displays the information about the current Linux version you are using. This command becomes important to us at it also displays the Kernel version of your system as well as the complete name of your Operating System which will usually contain the version of the Linux distribution you are running.

Advertisements

hostnamectl command will also display certain other system information like the ‘Machine Id’, ‘Boot Id’, ‘Architecture etc.

Example:

hostnamectl

Output:

Static hostname: ubuntu Pretty hostname: Ubuntu Icon name: computer-laptop Chassis: laptop Machine ID: 370fd6b6b45d432d82390b2e399303ac Boot ID: ee99a37bc511492d91b56a1ae5d117c7 Operating System: Ubuntu 18.04.5 LTS Kernel: Linux 4.15.0-112-generic Architecture: x86-64 gaurav@ubuntu:~$

From the output, you can see that my current Linux version is Ubuntu 18.04.5 LTS.

The commands explained in this tutorial, can be replicated with most of the Linux versions.


Conclusion

In this short tutorial, we have learned some easy commands you can use to find out your Linux version that your system is running. We also identified two important files on your system which can be viewed to find out the Linux distribution and its specific version.