How to check OS version using command line on Linux

How to check OS version using command line on Linux

Check Linux OS version on command line

Linux is an open source and free operating system currently available. There are various distributions of Linux. Ubuntu, Debian, Manjaro, Fedora, OpenSuse, RHEL, CentOS, Linux Mint, etc. are popular Linux variants. When installing software packages and security patches, the operating system version is important. In this tutorial, you will learn how to check the Linux OS version at the command line.

Check OS version on Linux

You can check the OS version using: lsb_release command:

lsb_release -a

uname It can also be used to check the OS version.

uname -r

using hostnamectl This command is also useful for checking the OS version.

hostnamectl

Operating system related information is also stored internally /etc/os-release To view the file, use the following command:

cat /etc/os-release

Checking OS version

The following is an example of output data that indicates the version of the operating system version.

1. lsb_release command

LSB stands for Linux Standard Base. of lsb_release The command displays information about your Linux distribution. To check the OS version: lsb_release command:

lsb_release -a

The output looks like this:

LSB Version:	n/a
Distributor ID:	ManjaroLinux
Description:	Manjaro Linux
Release:	18.1.5
Codename:	Juhraya

2. uname command

You can view the Linux kernel architecture, version, name, etc. using: uname command:

uname -srvo

The output looks like this:

Linux 4.19.91-1-MANJARO #1 SMP Sat Dec 21 11:18:44 UTC 2019 GNU/Linux

Or, to display only the OS version, enter the following command:

uname -r

The output looks like this:

4.19.91-1-MANJARO

3. Use of / etc / os-release file data

of /etc/os-release The file contains operating system related identification data. Can simply use cat Commands for displaying data etc/os-release File data:

cat /etc/os-release

The output looks like this:

NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.manjaro.org/"
SUPPORT_URL="https://www.manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
LOGO=manjarolinux

Four. hostnamectl Practicality

of hostnamectl The utility is part of SystemD used to change the host name. Use this utility to view information about your Linux distribution.

hostnamectl

The output looks like this:

   Static hostname: linux4one
         Icon name: computer-laptop
           Chassis: laptop
        Machine ID: 9331e16a9f024d05ad3da354c679382c
           Boot ID: ffe54918cf9e4a8f9be10479ab5a2bec
  Operating System: Manjaro Linux
            Kernel: Linux 4.19.91-1-MANJARO
      Architecture: x86-64

Five. /etc/*release Old Linux distribution files

If you are running a very old Linux Distro, all of the above methods may not work. So, to check the OS version of a very old computer, use the following command:

cat /etc/*release

Alternatively, you can check the only version using the following command:

cat /etc/*version

Conclusion

You learned how to check the OS version using the command line on Linux. If you have any questions, don’t forget to comment them out.

Sidebar