Sep 22, 2023 4 min read

How to Check Linux Version

Check Linux Version with our step-by-step tutorial. It is an open-source operating system and acts as a link between software and hardware.

Check Linux Version
Table of Contents

Introduction

Before we begin talking about how to check Linux version. Let’s briefly understand - What is Linux?

Linux is an open-source operating system for computers, servers etc. In its simplest form, Linux is a kernel, the central component of an operating system that serves as a link between software programs and hardware. A Linux distribution consists of a Linux kernel, GNU tools and libraries, and software collections. Desktop environments, package management systems, and a collection of preconfigured apps are usually included in Linux distributions.

Debian, Red Hat, Ubuntu, Arch Linux, Fedora, CentOS, Kali Linux, OpenSUSE, Linux Mint, and others are some of the most popular Linux distributions.

It's always a good idea to check what version of Linux is running on a Linux system before performing any work when you log in for the first time. Selecting the Linux distribution, for example, might assist you in determining the package manager to use when installing new packages.

This tutorial demonstrates how to use the command line to determine what Linux distribution and version is installed on your system. We will also address a few FAQs on how to check Linux Version.

lsb_release command

The LSB (Linux Standard Base) information about the Linux distribution is displayed by the lsb_release function. All Linux distributions with the lsb-release package installed should be able to run this command:

lsb_release -a
Output

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 9.5 (stretch)
Release:	9.5
Codename:	stretch

In the Description line, the Linux distribution and version are displayed. As you can see from the output, I'm running Debian GNU/Linux 9.5 (stretch) on my machine.

You can display the description line instead of publishing all of the above information, which indicates your Debian version if you use the -d flag.

lsb_release -d

You will get an output like below:

Output

Description:	Debian GNU/Linux 9.5 (stretch)

If you get the error "command not found: lsb_release," you can try some of the other techniques listed below to figure out what Linux version you have.

/etc/os-release file

The /etc/os-release file contains information on the distribution as well as operating system identification data. This file is included in the systemd package and should be present on any system that uses the systemd service.

Use cat or less to inspect the contents of the os-release file:

cat /etc/os-release

You will get an output like below:

Output

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
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

System identification text that is printed before the login prompt in present in the /etc/issue. It contains the information about the Linux version:

cat /etc/issue

You will get an output like below:

Output

Debian GNU/Linux 9 \n \l

hostnamectl command

The systemd tool hostnamectl is used to inquire and update the system hostname. The Linux distribution and kernel version are also displayed by this command.

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 instructions above work for you, you're probably running an ancient and out-of-date Linux distribution. You can use one of the following commands to print the contents of the distribution release or version file in this case:

cat /etc/*release
cat /etc/*version

uname command

The uname command displays system information such as the Linux kernel architecture, name, version, and release, among other things.

Type the following command to see what version of the Linux kernel is installed on your system:

uname -srm
Output

Linux 4.9.0-8-amd64 x86_64

The Linux kernel is 64-bit, and its version is "4.9.0-8-amd64," according to the report.

FAQs to Check Linux Version

Is it possible to check the Linux version without using the terminal?

Yes, you can check the Linux version by going to System Settings > About in many graphical user interfaces.

Can I determine the kernel version using the same commands?

No, to determine the kernel version, you should use the uname -r command.

Can I check the Linux version as a regular user, or do I need root privileges?

You can check the Linux version as a regular user; root privileges are not required for this task.

Are there any graphical tools available to check the Linux version?

Yes, there are graphical system information tools like "Hardinfo" or "Neofetch" that provide detailed information about the Linux distribution and version.

Is it possible to check the Linux version by examining the contents of the /proc/version file?

Yes, you can use the command cat /proc/version to view the Linux kernel version and some additional information.

How can I check the Linux version remotely on another machine?

You can use remote access tools like SSH to log in to the remote machine and then run the appropriate commands mentioned earlier to check the Linux version.

Is there a way to check the Linux version in scriptable output format?

Yes, you can use commands such as lsb_release -rs or cat /etc/os-release | grep "VERSION" to extract the Linux version in a scriptable format.

Conclusion

There are numerous commands that may be used to determine the Linux distribution and version that is installed on the machine.

You may also check your distribution and version using the graphical interface if you have a Linux distribution with a desktop environment.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.