OSETC TECH

How To Get the Kernel Version in Linux

This post will guide you how to check the kernel version in the Linux Operating systems. How do I find out the kernel version of my current CentOS or Ubuntu Linux server using uname command. How do I determine the Linux OS version.

Uname Command


Linux Uname command can be used to print certain system information. With no OPTION, same as -s. You can get the different system information through passing in different options.

-a, –all: print all information, in the following order, except omit -p and -i if unknown:

-s, –kernel-name: print the kernel name

-n, –nodename: print the network node hostname

-r, –kernel-release: print the kernel release

-v, –kernel-version: print the kernel version

-m, –machine:print the machine hardware name

-p, –processor:print the processor type (non-portable)

-i, –hardware-platform:print the hardware platform (non-portable)

-o, –operating-system:print the operating system

–help: display this help and exit

The syntax of the Uname command is as followss:

uname [OPTION]...

Print the Kernel Version Using Uname Command


If you only want to print the kernel version of the CentOS or RHEL or Ubuntu you are runnig, just type the following command at the shell prompt:

$ uname -r

Outputs:

devops@devops:~$ uname -r
5.0.0-27-generic

If you want to get the complete system information, you need to pass the -a option to the uname command, type:

$ uname -a

outputs:

devops@devops:~$ uname -a
Linux devops 5.0.0-27-generic #28~18.04.1-Ubuntu SMP Thu Aug 22 03:00:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Checking Linux OS Version


If you want to check Linux OS version from the command line, and you can use one of the following commands:

$ cat /etc/os-release
$ hostnamectl
$ lsb_release -r
$ cat /etc/issue

Outputs:

devops@devops:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

devops@devops:~$ hostnamectl
Static hostname: devops
Icon name: computer-vm
Chassis: vm
Machine ID: 515105f64e044178a110b50d86fd7f7d
Boot ID: 4455b26daba7477caff2b89e99dd4259
Virtualization: oracle
Operating System: Ubuntu 18.04.2 LTS
Kernel: Linux 5.0.0-27-generic
Architecture: x86-64

devops@devops:~$ lsb_release -d
Description: Ubuntu 18.04.2 LTS

devops@devops:~$ cat /etc/issue
Ubuntu 18.04.2 LTS \n \l

For CentOS or RHEL Linux, before using lsb_release command, you may be need to install the package “redhat-lsb” by the following yum command, type:

$ sudo yum install redhat-lsb

Outputs:

[root@osetc ~]# yum install redhat-lsb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 13 kB 00:00
* base: repos-lax.psychz.net
* epel: d2lzkl7pfhq30w.cloudfront.net
* extras: mirror.hostduplex.com
* remi-safe: mirrors.mediatemple.net
* updates: mirror.hostduplex.com
base | 3.6 kB 00:00
epel | 5.3 kB 00:00
extras | 3.4 kB 00:00
remi-safe | 3.0 kB 00:00
updates | 3.4 kB 00:00
(1/3): epel/x86_64/updateinfo | 1.0 MB 00:00
(2/3): epel/x86_64/primary_db | 6.8 MB 00:00
(3/3): remi-safe/primary_db | 1.6 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package redhat-lsb.x86_64 0:4.1-27.el7.centos.1 will be installed
--> Processing Dependency: redhat-lsb-printing = 4.1-27.el7.centos.1 for package: redhat-lsb-4.1-27.el7.centos.1.x86_64
.....
--> Finished Dependency Resolution

Dependencies Resolved

====================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================
Installing:
redhat-lsb x86_64 4.1-27.el7.centos.1 base 25 k
Installing for dependencies:
......
qt-settings noarch 19-23.8.el7.centos base 17 k
qt-x11 x86_64 1:4.8.7-3.el7_6 updates 13 M
qt3 x86_64 3.3.8b-51.el7 base 3.5 M
redhat-lsb-core x86_64 4.1-27.el7.centos.1 base 38 k
redhat-lsb-cxx x86_64 4.1-27.el7.centos.1 base 16 k
redhat-lsb-desktop x86_64 4.1-27.el7.centos.1 base 20 k
redhat-lsb-languages x86_64 4.1-27.el7.centos.1 base 18 k
redhat-lsb-printing x86_64 4.1-27.el7.centos.1 base 16 k
redhat-lsb-submod-multimedia x86_64 4.1-27.el7.centos.1 base 15 k
redhat-lsb-submod-security x86_64 4.1-27.el7.centos.1 base 15 k
spax x86_64 1.5.2-13.el7 base 260 k
systemtap-sdt-devel x86_64 3.3-3.el7 base 74 k
time x86_64 1.7-45.el7 base 30 k
urw-fonts noarch 2.4-16.el7 base 3.0 M
xdg-utils noarch 1.1.0-0.17.20120809git.el7 base 70 k
xorg-x11-font-utils x86_64 1:7.5-21.el7 base 104 k

Transaction Summary
====================================================================================================================================================
Install 1 Package (+133 Dependent packages)

Total download size: 45 M
Installed size: 140 M
Is this ok [y/d/N]:y

If you want to get more information for uname command, and you can also view the manual page or display the help using the following command:

$ man uname
$uname --help

Conclusion


You should know that how to check the kernel version using uname command in a CentOS or RHEL or Ubuntu Linux server.