There are many ways to check the linux version information

Posted by Hitwalker on Fri, 14 Jan 2022 20:34:00 +0100

Sometimes, we may need to obtain the version information of the Linux system for some special needs.

View Linux kernel version

Let's introduce some methods to obtain the system version. First, check the Linux kernel. There are two main methods:

cat@yafeile-pc:~/wheezy$ cat /proc/version 
Linux version 4.4.3-1-ARCH (builduser@tobias) (gcc version 5.3.0 (GCC) ) #1 SMP PREEMPT Fri Feb 26 15:09:29 CET 2016

We get the version information of the current kernel by reading the version file in the / proc directory. The proc directory is a pseudo file system process information, which provides an interface to access the kernel data structure. It is usually mounted in / proc and is mostly readable, but some files allow kernel variables to be modified.

The result of / proc/version is mainly composed of / proc/sys/kernel/ostype,/proc/sys/kernel/osrelease and / proc/sys/kernel/version:

cat@yafeile-pc:~$ cat /proc/sys/kernel/ostype
cat@yafeile-pc:~$ cat /proc/sys/kernel/osrelease
cat@yafeile-pc:~$ cat /proc/sys/kernel/version
#1 SMP PREEMPT Fri Feb 26 15:09:29 CET 2016

check Linux version

The second way to get the kernel version may be more familiar to us:

cat@yafeile-pc:~/wheezy$ uname -a
Linux yafeile-pc 4.4.3-1-ARCH #1 SMP PREEMPT Fri Feb 26 15:09:29 CET 2016 x86_64 GNU/Linux

We output the system information through the uname command.

View Linux system version

The next step is to view the Linux system version. There are three main methods. First, let's look at a general way to use lsb_release command:

cat@yafeile-pc:~/wheezy$ lsb_release -a
LSB Version:    1.4
Distributor ID:    Arch
Description:    Arch Linux
Release:    rolling
Codename:    n/a

Where LSB_ The release command is used to print the determined LSB(Linux Standard Base) and version information.

This operation obtains the LSB from the / etc / LSB release file_ Version field, which is the number of LSB. Then there is the optional DISTRIB_ID,DISTRIB_RELEASE,DISTRIB_CODENAME and DISRRIB_DESCRIPTION can be used to rewrite information.

Next, you will view the / etc / [district] - release file, including the release version and other information. We can use the following methods to obtain the files containing release:

cat@yafeile-pc:~/wheezy$ ls /etc|grep release

Then view its contents:

cat@yafeile-pc:~/wheezy$ cat /etc/arch-release 
Arch Linux release
cat@yafeile-pc:~/wheezy$ cat /etc/lsb-release 

The next common method is to view the issue file:

cat@yafeile-pc:~/wheezy$ cat /etc/issue 
Arch Linux \r (\l)

As you can see, this is really much streamlined.

The following method can only be used for a specific release:

cat@debian:~$ cat /etc/debian_version

We get debian in the / etc directory_ The debian version is obtained from the version file, which is currently 7.10. In addition, the OS release file also contains version information about the system:

cat@debian:~$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION="7 (wheezy)"

As you can see, this is much more detailed than the above content.

check ip address in Linux