Linux is a free and open-source operating system and it has various distributions such as Ubuntu, Red Hat, Debian, Fedora, CentOS, OpenSUSE, and Arch. Every Linux operating system has a Linux Kernel, software collections, and GNU tools and libraries. Determining the Linux distribution, Kernel version, and Linux version is very important to figure out which package manager to use for installing new packages.
Linux operating system version is the very first thing we need to know before installing software, applying security updates, applying bug fixes, or deciding which development framework to use. When you install bug fixes or security updates, your OS version changes.
In this tutorial, we learn how to check the Linux OS Version.
Differences between OS and Kernel Version?
Linux OS is a system software that provides an interface between the computer and the user. When your computer boots, the OS is the first software that loads. However, Kernel is the base of the Linux operating system that converts commands to machine language.
The Linux OS version is not always the same as the Kernel version. OS release means the stable version of the Linux distribution, but the Linux Kernel version is the build number of the source Kernel that is used as a base of the operating system. A version of every package is associated with the Kernel version.
Commands to Check Linux Version
The following table lists some of the most common ways to identify Linux OS version:
|OS release file that contains OS name and version information|
|Displays Linux Standard Base (LSB) information about the operating system, including release codename and version number|
|Displays Linux Kernel and GCC version of your Linux distribution|
|Displays Linux OS distribution name, computer hostname, Kernel release, and system hardware architecture|
|File content contains Distribution version information|
|Displays only the Linux Kernel version|
How to Check Linux OS Version
There are a variety of ways to check the Linux OS versions, based on your Linux distribution. For example, the lsb_release packages are not installed on Red Hat Linux distractions by default, and the hostnamectl command works only on the systemd based distributions.
The following command examples show you how to check the OS version on your Linux system:
The /etc/os-release File
The /etc/os-release file contains Linux OS identification information, which includes Linux distribution name and distribution version.
Run the following cat command on the /etc/os-release file to check the configuration of your Linux system:
You can also type the following command to filter out OS Version information:
grep ‘^VERSION’ /etc/os-release
The lsb_release Command
Use the lsb_release command line utility to display Linux Standard Base (LSB) information about the Linux distribution installed on your system. It shows details such as release codename, Linux version number, and distributor ID.
The lsb_release command is part of the software package known as the LSB core, and it is not installed by default on various Linux distributions, such as Red Hat and CentOS.
This command provides different options to display specific information, such as
-v for version,
-i for operating system identification data,
-r for release,
-a for all, and
-d for description.
For example, the following command displays all release related information about your Linux distribution:
The Inxi Tool
The Inxi is a powerful command line script that provides system information. This command line utility can be used to display hardware configuration, system configuration, GCC version, Linux Kernel version number, and a variety of other useful information.
For example, use the
inxi -b command to display all configuration information about your Linux system:
The hostnamectl Command
When used without any options, hostnamectl can be used to display static hostname, machine ID, boot ID, virtualization, OS name and version, and Kernel release. For example:
You may also use the hostnamectl command to update static hostname and transient hostname.
To check the system information you can use uname command. You can use
-a option to print all information that includes OS Version.
You may use
-r option to check the Linux Kernel version:
The /etc/issue file
/etc/issue file contains system identification information that is displayed before the login prompt.
You can use more, less, or cat command to view the content of the file:
You may also find Linux distribution-related information in
/etc/*release file. This is mostly found in old release versions.
In this tutorial, we learned about different ways to check the Linux OS version. Some commands have Linux distribution dependence so try which one works for you.