Linux get linux kernel version

How do I find out the kernel version I am running?

I need this info so I can finish updating my STA Broadcom wireless. However, I’m a noob at Ubuntu and I’m not sure how to find the kernel version or kernel. I checked /lib/modules/ and found this:

2.6.27-10-generic 2.6.32-30-generic 2.6.32-34-generic 2.6.32-38-generic 2.6.27-7-generic 2.6.32-31-generic 2.6.32-35-generic 3.2.0-54-generic 2.6.28-19-generic 2.6.32-32-generic 2.6.32-36-generic 3.2.0-54-generic-pae 2.6.31-23-generic 2.6.32-33-generic 2.6.32-37-generic 

Which one is the running kernel? Another question. Is there a snippet so I don’t have to cut and paste? Thanks for your time! 🙂

6 Answers 6

Well there are multiple ways to find the kernel version

Open terminal and execute:

It would display something like:

You can get further information on the current kernel with

It would display something like:

Linux saurav-P4I45Gx-PE 3.8.0-30-generic #44~precise1-Ubuntu SMP Fri Aug 23 17:33:45 UTC 2013 i686 i686 i386 GNU/Linux 

Another way to know the kernel version is to open Synaptic Package Manager and search for linux image . You have to check for the installed Kernel version.

Another way to find version of installed kernels is to run this command:

dpkg -l | grep linux-image | grep ii 

or for just the version strings:

dpkg -l | grep linux-image | grep ii | awk '' 

The latest kernel (the one with the highest version number) will boot by default, so if you have rebooted since the last kernel update, and you have not made adjustments to boot into a kernel other than the default, then you can be reasonably confident that the highest version number displayed will be the version of the running kernel, but you should use uname for more reliable information.

Источник

5 easy & useful ways to check Linux kernel version

In this tutorial I will share multiple commands and methods you can use to check the Linux kernel version. We know that kernel is the core component in Linux and it is important that you know what version of kernel the system is running.

Method 1: Check Linux kernel version using uname

uname is the most handy tool which is used to print the system information.

On RHEL/CentOS/Fedora

In the provided distributions the output of uname would be similar to

~]# uname -r 4.18.0-193.14.2.el8_2.x86_64

The output can be broken into below format

  • 4.18.0 is the major version
  • 193.14.2 is the minor version
  • el8_2 is the release
  • x86_64 is the architecture
Читайте также:  Интерфейс командной строки линукс

To list the installed kernel:

~]# rpm -q kernel kernel-4.18.0-80.el8.x86_64 kernel-4.18.0-147.5.1.el8_1.x86_64 kernel-4.18.0-193.14.2.el8_2.x86_64

On SLES/OpenSuSE

The output of uname would be different with SLES release which is again the kernel version for SLES platform.

# uname -r 3.0.101-108.81-default

You can use uname -a to get more details on the kernel version, system architecture etc

# uname -a Linux cc01-nds-ins 3.0.101-108.81-default #1 SMP Fri Nov 2 18:02:20 UTC 2018 (2208a0f) x86_64 x86_64 x86_64 GNU/Linux

To list the installed kernel:

~ # rpm -q kernel-default kernel-default-3.0.101-108.81.1

On Ubuntu/Debian

In the provided distribution, kernel is referred as linux-image . The kernel versions of Ubuntu/Debian are assigned by the respective developers and they don’t follow the normal naming syntax or standards.

Output from my Ubuntu server:

  • 5 is the major version
  • 0 from the second field is the minor version
  • 0 from the third field is the patch level
  • 23-generic is the developer patch level and in our context is what is assigned by the Ubuntu developers.

To list the available kernel package, you can use:

:~# dpkg --list | grep linux-image ii linux-image-5.0.0-23-generic 5.0.0-23.24~18.04.1 amd64 Signed kernel image generic ii linux-image-generic-hwe-18.04 5.0.0.23.80 amd64 Generic Linux kernel image

Method 2: Check Linux kernel version using hostnamectl

You may not find this command if you are using older releases. hostnamectl may be used to query and change the system hostname and related settings. But it also prints the kernel information.

The output of this command would be same across all Linux distributions. Below is an output from RHEL 8 server:

5 easy & useful methods to check Linux kernel version

Method 3: Check Linux kernel version using grubby

grubby is only available in RHEL/CentOS/Fedora/SuSE distribution i.e. it is not yet available in Debian/Ubuntu (at the time of writing this article). grubby is a command line tool used to configure bootloader menu entries across multiple architectures.

To list the default kernel version:

~]# grubby --default-kernel /boot/vmlinuz-4.18.0-193.14.2.el8_2.x86_64

To get more information on this kernel, we can use » grubby —info /boot/vmlinuz-4.18.0-193.14.2.el8_2.x86_64 «. Following is an output from my server:

5 easy & useful methods to check Linux kernel version

Method 4: Check Linux kernel version using boot log messages

4.1: Using dmesg

In most distributions we use dmesg to access the boot up log messages which also contains the kernel version along with many other details.

Output from RHEL/CentOS/Fedora

~]# dmesg | grep "Linux version" [ 0.000000] Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020

Output from Ubuntu/Debian

~# dmesg | grep "Linux version" [ 0.000000] Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 (Ubuntu 5.0.0-23.24~18.04.1-generic 5.0.15)

Output from SLES

# dmesg | grep "Linux version" [ 0.000000] Linux version 3.0.101-108.81-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP Fri Nov 2 18:02:20 UTC 2018 (2208a0f)

4.2: Using journalctl

In recent Linux distributions we have journalctl which gives us more flexibility in reading and accessing the log messages. To check the boot up log messsages we use -b switch with journalctl command

Читайте также:  Linux how to install deb package

Output from RHEL/CentOS/Fedora

~]# journalctl -b | grep "Linux version" Sep 18 11:50:55 server.example.com kernel: Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020

Output from Ubuntu/Debian

~# journalctl -b | grep "Linux version" Sep 18 11:50:51 deepak-VirtualBox kernel: Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 (Ubuntu 5.0.0-23.24~18.04.1-generic 5.0.15)

Currently I don’t have access to SLES 12 or higher so I can’t post the output but the same command would work with any SLES release higher than SLES 12.

Method 5: Check content of /proc/version

The output which you got earlier in Method 4 by grepping » Linux version » from the boot log files is actually collected from /proc/version. So if you do not wish to go through the log files, you can directly check the content of this file to get the Linux kernel version

Output from RHEL/CentOS/Fedora

~]# cat /proc/version Linux version 4.18.0-193.14.2.el8_2.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Sun Jul 26 03:54:29 UTC 2020

Output from SuSE/OpenSuSE

# cat /proc/version Linux version 3.0.101-108.81-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP Fri Nov 2 18:02:20 UTC 2018 (2208a0f)

Output from Ubuntu/Debian

~# cat /proc/version Linux version 5.0.0-23-generic (buildd@lgw01-amd64-030) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019

Conclusion

In this tutorial I shared multiple commands and methods to check Linux kernel version across multiple distributions such as Ubuntu, Red Hat, CentOS, Fedora, SuSE etc. Some of the commands may not work on all the distributions which I have already highlighted wherever applicable.

Lastly I hope the steps from the article to configure NIC teaming on Linux was helpful. So, let me know your suggestions and feedback using the comment section.

Didn’t find what you were looking for? Perform a quick search across GoLinuxCloud

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Источник

3 Ways to Check Linux Kernel Version in Command Line

You may find yourself in a situation where you need to know the exact Linux kernel version used on your system. Thanks to the powerful Linux command line, you can easily find that out.

A quick way to check Linux kernel version: You can use the following command to get the Linux kernel version:

There are other ways to get even more detailed information about kernels. Read the rest of the article to learn it in detail.

In this article, I’ll show you various methods for finding out your kernel version and tell you what those numbers mean. If you prefer videos, here’s a quick one:

Check Kernel Version In Linux

1. Find Linux kernel using uname command

uname is the Linux command for getting system information. You can also use it to find out whether you’re using a 32-bit or 64-bit system.

Читайте также:  Atheros ar9271 drivers linux

Open a terminal and type in the following command:

Checking Linux kernel version in command line

The output will be something similar to this:

This means that you’re running Linux kernel 4.4.0-97, or in more generic terms, you are running Linux kernel version 4.4.

But what do the other digits mean here? Let me explain:

  • 4 – Kernel version
  • 4 – Major revision
  • 0 – Minor revision
  • 97 – Bug fix
  • generic – Distribution-specific string. For Ubuntu, it means I’m using the desktop version. For Ubuntu server edition, it would be ‘server’.

You can also use the uname command with the option -a. This will provide more system information if you need it.

Checking Linux kernel version in command line

The output of the command should look like this:

Linux itsfoss 4.4.0-97-generic #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Let me explain the output and what it means:

  • Linux – Kernel name. If you run the same command on BSD or macOS, the result will be different.
  • itsfoss – Hostname.
  • 4.4.0-97-generic – Kernel release (as we saw above).
  • #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 – This means that Ubuntu has compiled 4.4.0-97-generic 120 times. A timestamp for the last compilation is also there.
  • x86_64 – Machine architecture.
  • x86_64 – Processor architecture.
  • x86_64 – Operating system architecture (you can run a 32-bit OS on a 64-bit processor).
  • GNU/Linux – Operating system (and no, it won’t show the distribution name).

But I’ll save you from information overload. Let’s see some other commands to find your Linux kernel version.

2. Find Linux kernel using /proc/version file

In Linux, you can also find the kernel information in the file /proc/version. Just look at the contents of this file:

Checking Linux kernel version in command line

You’ll see an output similar to what you saw with uname.

Linux version 4.4.0-97-generic ([email protected]) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017

You can see the kernel version 4.4.0-97-generic here.

3. Find Linux kernel version using dmesg command

dmesg is a powerful command used for writing kernel messages. It’s also very useful for getting system information.

Since dmesg provides an awful lot of information, you should normally use a command like less to read it. But since we’re here just to check the Linux kernel version, grepping on ‘Linux’ should give the desired output.

Checking Linux kernel version in command line

The output will have a few lines but you should be able to identify the Linux kernel version there easily.

[ 0.000000] Linux version 4.4.0-97-generic ([email protected]) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 (Ubuntu 4.4.0-97.120-generic 4.4.87) [ 0.182880] [Firmware Bug]: ACPI: BIOS _OSI(Linux) query ignored [ 1.003861] Linux agpgart interface v0.103 [ 1.007875] usb usb1: Manufacturer: Linux 4.4.0-97-generic xhci-hcd [ 1.009983] usb usb2: Manufacturer: Linux 4.4.0-97-generic xhci-hcd [ 5.371748] media: Linux media interface: v0.10 [ 5.399948] Linux video capture interface: v2.00 [ 5.651287] VBoxPciLinuxInit

How do you check your Linux Kernel version and other information?

Of the three ways discussed here, I use uname all the time. It’s the most convenient.

What about you? Which command do you prefer for getting Linux kernel information?

Источник

Оцените статью
Adblock
detector