Home » Linux » How to Check OS Version in Linux
February 25, 2021 by Kiet Duong

How to Check OS Version in Linux

check linux os version

When audiences refer to Linux, they generally refer to a distribution of Linux. Technically speaking, Linux is a kernel that simply puts functions as an interface between computer programs and hardware.

Kernel, the fundamental component of the OS. A Linux distribution is an OS made of Linux kernel, libraries, GNU, and applications. Linux distributions usually provide desktop operating environments, a package management framework, and a collection of preinstalled software.

To install the essential packages and apply the necessary security fixes, it is important to know the existing operating system, its versions, and also the Linux kernel version on your operating system. Not just that, being a system administrator, understanding the system often comes in handy for troubleshooting problems. 

This article explains how to verify the version and distribution of Linux installed on your device while using the command line.

lsb_release Command

The lsb_release tool shows LSB (Linux Standard Base) Linux distribution information.  This command should operate on all distributions of Linux that have installed the lsb-release package:

lsb_release -a

Output

No LSB modules are available.

Distributor ID: Debian

Description: Debian GNU/Linux 9.5

Release: 9.5

Codename: stretch

In the description line, the Linux distribution and version are being shown. It has Debian GNU/Linux 9.5 (stretch) mounted on the device, as you can see from the data above.

You can display the description line, which shows your Debian version passing the -d switch.

lsb_release -d

The output looks like this:

Description:  Debian GNU/Linux 9.5 (stretch)

You should try to find the Linux version using any of the other methods below if you get ‘command not found: lsb release’.

/etc/os-release file 

This file includes identification data for the operating system, including distribution information. This file should be present on all systems running systemd.

To display the contents of the os-release file, either using cat or less: 

cat /etc/os-release

The output should look like:

PRETTY_NAME="Debian GNU/Linux 9"

NAME="Debian GNU/Linux"

VERSION_ID="9"

VERSION="9 (stretch)"

ID=debian

HOME_URL="https://www.debian.org/"

SUPPORT_URL="https://www.debian.org/support"

BUG_REPORT_URL=https://bugs.debian.org/

/etc/issue file 

The file includes the system identifier text that is displayed well before prompt for login. This file usually contains details about the Linux version:

cat /etc/issue

The output should look like this:

Debian GNU/Linux 9 \n \l

hostnamectl command 

hostnamectl utility is a component of the systemd package which is used for querying and modifying the hostname of the system. It also shows the Linux distribution and kernel version.

hostnamectl

Output

Static hostname: debian9.localdomain

 Icon name: computer-vm

 Chassis: vm

 Machine ID: a92099e30f704d559adb18ebc12ddac4

 Boot ID: 7607cbe605d44f638d6542d4c7b3878e

 Virtualization: qemu

 Operating System: Debian GNU/Linux 9 (stretch)

 Kernel: Linux 4.9.0-8-amd64

 Architecture: x86-64

/etc/*release file 

If none of the above commands executes for you, then you are most probably running a very old and obsolete Linux distribution. In this case, one of the following commands may be used to print the distribution release or version file content:

Enter the following command to figure out what version of the Linux kernel is installed on your system:

cat /etc/*release

cat /etc/*version

uname command 

Several system information, including the Linux kernel architecture, name, version, and release, are displayed by the uname command.

uname -srm

The output should look like this:

Linux 4.9.0-8-amd64 x86_64

The output shows Linux kernel is 64-bit, and its version is “4.9.0-8-amd64.

There are a number of different functions that can help you figure out which version of the Linux distribution is operating on your device.

You can also check distribution and version from the graphical interface if you have desktop-enabled Linux distribution.

0

Comments

Likes

Tags

Leave a Reply

Your email address will not be published.