Find Linux Kernel Version Command

last updated in Categories , ,

How do I find out my Linux kernel version? How can I find the kernel version at shell prompt on Linux?

Linux stores version information in a file called /proc/version. As a sysadmin you need to know the Linux distro ver number of the Linux kernel on given server or workstation. This information can be used for the following purpose:

  1. To fix device driver issue.
  2. Install correct device driver for NIC/RAID card.
  3. Diagnosing system problems.
  4. Security and patching system for bugs.
  5. Upgrading system and more.

This page explains various command line options to find your running kernel version.

How to find Linux kernel version

You need to type the following command at shell prompt:
$ uname -r
Sample outputs from RHEL 5:

2.6.18-194.3.1.el5

Another outputs from Fedora 30:

5.1.16-300.fc30.x86_64

How to check Linux version using /prov/version file

Type the following cat command to print out information about the running Linux kernel:
$ cat /proc/version
Sample outputs from RHEL 5:

Linux version 2.6.18-194.3.1.el5 (mockbuild@x86-004.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Sun May 2 04:17:42 EDT 2010

Please note that you can also use the following command:
$ uname -a
Sample outputs:

Linux b1 3.2.0-51-generic #77-Ubuntu SMP Wed Jul 24 20:18:19 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Another outputs from my Fedora Linux desktop:
Check Linux Kernel Version in Command Line

Checking Linux kerne version using dmesg

Another useful option is to type the following dmesg command along with grep command:
dmesg | grep 'Linux version'
dmesg | grep Linux

Sample outputs:

[    0.000000] Linux version 5.1.16-300.fc30.x86_64 (mockbuild@bkernel04.phx2.fedoraproject.org) (gcc version 9.1.1 20190503 (Red Hat 9.1.1-1) (GCC)) #1 SMP Wed Jul 3 15:06:51 UTC 2019
[    0.667677] SELinux:  Initializing.
[    0.667697] *** VALIDATE SELinux ***
[    0.691958] ACPI: Added _OSI(Linux-Dell-Video)
[    0.691958] ACPI: Added _OSI(Linux-Lenovo-NV-HDMI-Audio)
[    0.691958] ACPI: Added _OSI(Linux-HPI-Hybrid-Graphics)
[    0.808940] pps_core: LinuxPPS API ver. 1 registered
[    1.754325] Linux agpgart interface v0.103
[    1.788277] usb usb1: Manufacturer: Linux 5.1.16-300.fc30.x86_64 xhci-hcd
[    1.789649] usb usb2: Manufacturer: Linux 5.1.16-300.fc30.x86_64 xhci-hcd
[   31.626968] SELinux:  policy capability network_peer_controls=1
[   31.626970] SELinux:  policy capability open_perms=1
[   31.626970] SELinux:  policy capability extended_socket_class=1
[   31.626971] SELinux:  policy capability always_check_network=0
[   31.626972] SELinux:  policy capability cgroup_seclabel=1
[   31.626972] SELinux:  policy capability nnp_nosuid_transition=1
[   31.653735] systemd[1]: Successfully loaded SELinux policy in 755.735ms.
[   32.980279] Intel(R) Wireless WiFi driver for Linux
[   34.349592] VBoxPciLinuxInit
[ 1784.165279] SELinux:  Converting 2546 SID table entries...
[ 1786.470382] SELinux:  policy capability network_peer_controls=1
[ 1786.470383] SELinux:  policy capability open_perms=1
[ 1786.470383] SELinux:  policy capability extended_socket_class=1
[ 1786.470383] SELinux:  policy capability always_check_network=0
[ 1786.470384] SELinux:  policy capability cgroup_seclabel=1
[ 1786.470384] SELinux:  policy capability nnp_nosuid_transition=1
[ 1804.575674] SELinux:  Converting 2559 SID table entries...
[ 1807.034856] SELinux:  policy capability network_peer_controls=1
[ 1807.034857] SELinux:  policy capability open_perms=1
[ 1807.034858] SELinux:  policy capability extended_socket_class=1
[ 1807.034859] SELinux:  policy capability always_check_network=0
[ 1807.034859] SELinux:  policy capability cgroup_seclabel=1
[ 1807.034860] SELinux:  policy capability nnp_nosuid_transition=1

Using hostnamectl command

Simply run the following hostnamectl command on systemd based distros:
hostnamectl
Sample outputs:

   Static hostname: mum1-vpn1
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 612892249edc4cf7b40cdfd1534feded
           Boot ID: f6285443d8544cb1a04878e0f2b13056
    Virtualization: kvm
  Operating System: Ubuntu 18.04.2 LTS
            Kernel: Linux 4.15.0-54-generic
      Architecture: x86-64

The above command displays both the Linux distribution and kernel version.

More About Kernel Version Release Numbers Between 1.0 and 2.6.x

The kernel used odd minor version numbers to denote development releases and even minor version numbers to denote stable releases; For example, version 2.3 was a development version and Linux 2.4 was the stable version. Since 2004 release of the v2.6 kernel, Linux no longer uses this system, and has a much shorter release cycle, instead now simply incrementing the third number, using a fourth number as necessary.

Related media

This tutorial is also available in a quick video format:


Conclusion

You leaned how to find the version of the Linux kernel running on your system and works with Debian, Ubuntu, Fedora, RHEL, CentOS, OpenSUSE, Arch, Gentoo and all other distros.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive