The Linux kernel is the core component of a Linux operating system. It handles processes, memory, devices, networking, and other essential functions. Knowing your Linux kernel version is important for troubleshooting, compatibility checking, and upgrading purposes.

In this comprehensive guide, I will show you 10 different ways to check your current Linux kernel version from the command line. We will cover both simple one-line version checks as well as viewing more detailed kernel information.

1. Check Kernel Version with uname

The uname command displays basic system information including the kernel version:

uname -r

This will print the running kernel release number:

5.15.0-56-generic

Breaking this down:

  • 5 – Major kernel version number
  • 15 – Minor version number
  • 0-56 – Revision number
  • generic – Indicates architecture type

To view all information uname can provide:

uname -a

Output:

Linux ubuntu-server 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

This includes the kernel name (Linux), hostname (ubuntu-server), kernel release, version, and architecture.

2. Check with /proc/version

The Linux /proc virtual filesystem contains information about running processes and the system. View the kernel version from /proc/version:

cat /proc/version

Output:

Linux version 5.15.0-56-generic (buildd@lcy02-amd64-025) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022

This provides the full kernel string along with additional build details.

3. Use dmesg

dmesg shows kernel ring buffer information. Use it to view boot messages including the running kernel version:

dmesg | grep -i linux

Output excerpt:

[    0.000000] Linux version 5.15.0-56-generic (buildd@lcy02-amd64-025) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022

Search for "Linux version" to get the kernel string.

4. Check with hostnamectl

The hostnamectl command prints system information. Use it to view kernel details:

hostnamectl | grep -i kernel

Output:

  Kernel: Linux 5.15.0-56-generic

It will directly show the running kernel name and version.

5. Use /proc/cmdline

The /proc/cmdline file shows the full kernel command line arguments used at boot time:

cat /proc/cmdline

Output:

BOOT_IMAGE=/vmlinuz-5.15.0-56-generic root=UUID=d3ed759f-XXXX ro quiet splash vt.handoff=7

The kernel image name here is /vmlinuz-5.15.0-56-generic which contains the version.

6. Check with /boot

The /boot directory contains kernel files including the grub config:

cat /boot/grub/grub.cfg  

Searching this file will reveal the currently running kernel string:

linux   /vmlinuz-5.15.0-56-generic root=UUID=d3ed759f-XXXX ro  quiet splash $vt_handoff

You can also view the kernel filename directly:

ls /boot | grep vmlinuz

Output:

vmlinuz-5.15.0-56-generic

7. Use the sysctl utility

sysctl gets/sets kernel parameters at run time:

sysctl kernel.osrelease

Output:

kernel.osrelease = 5.15.0-56-generic

This prints the kernel release number.

There are many other relevant sysctl parameters such as:

sysctl kernel.version
sysctl kernel.runningkernel

8. Check /etc/os-release

The /etc/os-release file contains distro identification data including the kernel version number for modern Linux systems:

cat /etc/os-release | grep -i kernel

Output:

VERSION_CODENAME=focal
KERNEL_VERSION=5.15.0-56-generic

Directly shows running kernel release.

9. Use the neofetch System Info Tool

Neofetch is an awesome command line system info and logo printing tool. Install it with:

sudo apt install neofetch

Then run it to view kernel alongside other system details:

neofetch

Output includes the kernel version:

OS: Ubuntu 20.04.5 LTS x86_64 
Kernel: 5.15.0-56-generic

Neofetch even prints an ASCII distribution logo!

10. Install and Use screenfetch

screenFetch is a similar system information tool to neofetch. After installation, run it to view kernel version in ASCII art form:

screenfetch

Output:

                  mohhhhh-               user@ubuntu
               yhhhhhh+`                --------------
              mhhhhhhh+                  OS: Ubuntu 20.04.5 LTS x86_64
            -dhhhhhhho                    Kernel: 5.15.0-56-generic
         `ohhhhhhh/                     Uptime: 2m
       `yhhhhhyo`                       Packages: 1985
     -yhhhhh/                           Shell: bash 5.0.17
    ohys+/                              Resolution: 1920x1080
   syo`                                 DE: GNOME
                                  Terminal: /dev/pts/0
                                  CPU: Intel i7-8700 (12) @ 3.200GHz
                                  GPU: Intel UHD Graphics 630
                                  GPU: NVIDIA GeForce GTX 1060 6GB
                                  Memory: 3248MiB / 15982MiB  

It‘s an easy way to display kernel version artistically on the terminal!

Conclusion

I‘ve demonstrated 10 handy ways to check your current Linux kernel release, version, and additional details directly from the terminal.

Methods covered included common commands like uname, dmesg, hostnamectl, sysctl, as well as viewing /proc and /etc filesystem output. We also looked at fun specialty tools like neofetch and screenfetch that format system data like kernel beautifully.

Knowing how to check your Linux kernel version is crucial for system administration tasks as well as compatibility checking before upgrading programs, drivers or hardware.

Similar Posts