4 Ways to check Linux Version

Table of Contents

The OS version of a Linux distribution can be determined by using the command-line interface as well as a graphical user interface.

In Linux, CLI is preferred over GUI as it provides more control over the OS.

In this article, we will mostly focus on the command line methods which can be used to check the OS version of a Linux distribution.

 

Command Example
uname -a
$uname -a
Linux ip-10-0-0-224 5.4.0-1045-aws
#47-Ubuntu SMP Tue Apr 13 07:02:25 UTC
2021 x86_64 x86_64 x86_64 GNU/Linux
more /proc/version
$ more /proc/version
Linux version 5.4.0-1045-aws
(gcc version 9.3.0
(Ubuntu 9.3.0-17ubuntu1~20.04))
more /etc/os-release $ more /etc/os-release
NAME=”Ubuntu”
VERSION=”20.04.2 LTS (Focal Fossa)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 20.04.2 LTS”
VERSION_ID=”20.04″
lsb_release -a $lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal

 

Check OS version with uname command

We will use uname command, which is used to print our Linux system information such as kernel version and release name, network hostname, machine hardware name, processor architecture, hardware platform and the operating system.

The command uname -a shows the version of the Linux kernel you’re using, as well as additional details.

uname -a

Linux deb-srv 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux

Find Linux version from /proc/version

The /proc/version file specifies the version of the Linux kernel, the version of gcc used to compile the kernel, and the time of kernel compilation. It also contains the kernel compiler’s user name.

$ cat /proc/version

Get Linux version from /etc/os-release

The best way to determine a Linux distribution name and release version information is using cat /etc/os-release command, which works on almost all Linux system.

If we are running a very old Linux distribution then we might not be able to use any of the above commands. Use the following command to know the OS version on our old system:

cat /etc/*release

  • ———- On Red Hat Linux ———-
    $ cat /etc/redhat-release
  • ———- On CentOS Linux ———-
    $ cat /etc/centos-release
  • ———- On Fedora Linux ———-
    $ cat /etc/fedora-release
  • ———- On Debian Linux ———-
    $ cat /etc/debian_version
  • ———- On Ubuntu and Linux Mint ———-
    $ cat /etc/lsb-release
  • ———- On Gentoo Linux ———-
    $ cat /etc/gentoo-release
  • ———- On SuSE Linux ———-
    $ cat /etc/SuSE-release

Check Linux version with lsb_release command

The lsb_release command is a helpful utility to find out information about our Linux installation. It displays LSB (Linux Standard Base) information about the Linux distribution.

lsb_release -a
Output
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

Table of Contents

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

You might also like