Home Kernel module Display Linux Kernel Module Information With Modinfo Command

Display Linux Kernel Module Information With Modinfo Command

By sk

This brief guide explains what is Linux Kernel module, how to list the currently loaded Kernel modules using lsmod, and how to display Linux Kernel module information with modinfo command in Linux.

What is Linux Kernel module?

Linux Kernel is the main component of a GNU/Linux operating system. The functionality of the Linux Kernel can be extended without the need to reboot the system using Kernel modules. A Kernel module is a piece of code that can be loaded and unloaded into the kernel upon demand.

Some examples of Kernel modules are firmware and device drivers, which allows the Linux Kernel to access and control hardware connected to the system. Generally, the Kernel modules are used to add support for new hardware (as device drivers), and/or filesystems, or for adding system calls.

Without Kernel modules, we have to rebuild and reboot the kernel every time we want a new functionality. We also need to build bigger monolithic kernels and add new functionality directly into the kernel image without Kernel modules. With the help of a Kernel modules, we can simply avoid these problems.

Kernel modules are usually stored under Modules are stored in /usr/lib/modules/<kernel_release_directory>.

$ ls /usr/lib/modules/5.11.18-300.fc34.x86_64/
 bls.conf                   modules.builtin.bin      modules.symbols
 build                      modules.builtin.modinfo  modules.symbols.bin
 config                     modules.dep              source
 extra                      modules.dep.bin          symvers.gz
 kernel                     modules.devname          System.map
 modules.alias              modules.drm              updates
 modules.alias.bin          modules.modesetting      vdso
 modules.block              modules.networking       vmlinuz
 modules.builtin            modules.order            weak-updates
 modules.builtin.alias.bin  modules.softdep

Kernel modules are referred with different names in different operating systems. For example, a Kernel module is referred as kernel loadable module (kld) in FreeBSD, kernel extension (kext) in macOS, kernel extension module in AIX, kernel-mode driver in Windows NT, and downloadable kernel module (DKM) in VxWorks. They are also known as kernel loadable modules (or KLM), and simply as kernel modules (KMOD).

List Linux Kernel modules using lsmod command

We can view the list of Kernel modules that are currently loaded into the Kernel using lsmod (list modules) command like below:

$ lsmod

Sample output:

 Module                  Size  Used by
 vhost_net              32768  0
 vhost                  57344  1 vhost_net
 vhost_iotlb            16384  1 vhost
 tap                    28672  1 vhost_net
 tun                    57344  1 vhost_net
 rfcomm                 90112  4
 snd_seq_dummy          16384  0
 snd_hrtimer            16384  1
 xt_CHECKSUM            16384  1
 xt_MASQUERADE          20480  3
 xt_conntrack           16384  1
 ipt_REJECT             16384  2
 nf_nat_tftp            16384  0
 nf_conntrack_tftp      20480  3 nf_nat_tftp
 bridge                290816  0
 stp                    16384  1 bridge
 llc                    16384  2 bridge,stp
 ccm                    20480  6
 nft_objref             16384  2
 nf_conntrack_netbios_ns    16384  1
 nf_conntrack_broadcast    16384  1 nf_conntrack_netbios_ns
 nft_fib_inet           16384  1
List Linux Kernel modules using lsmod command
List Linux Kernel modules using lsmod command

The lsmod command gets the details of currently loaded Kernel modules from the file /proc/modules.

Hope you get the basic idea of what is Linux Kernel modules and how to list the currently loaded modules in Linux Kernel. Let us move ahead and see how to view the details of a specific Kernel module.

Display Linux Kernel module information with modinfo command

The modinfo command shows the detailed information of a given Kernel module. By default, it lists the attributes of a Kernel module in the form of fieldname : value, for easy reading.

To display the information of a Linux Kernel module, for example 88XXau, which is the TP-Link AC600 (Archer T2U Nano) Wireless adapter, run:

$ modinfo 88XXau

Sample output:

filename:       /lib/modules/5.11.18-300.fc34.x86_64/extra/88XXau.ko.xz
 version:        v5.6.4.2_35491.20191025
 author:         Realtek Semiconductor Corp.
 description:    Realtek Wireless Lan Driver
 license:        GPL
 srcversion:     4EC0EE17404B8E38B323235
 alias:          usb:v7392pB611ddcdscdpiciscipin
 alias:          usb:v7392pA813ddcdscdpiciscipin
 alias:          usb:v7392pA812ddcdscdpiciscipin
 alias:          usb:v7392pA811ddcdscdpiciscipin
 alias:          usb:v3823p6249ddcdscdpiciscipin
 alias:          usb:v2357p0122ddcdscdpiciscipin
 alias:          usb:v2357p0120ddcdscdpiciscipin
Display Linux Kernel module information with modinfo command
Display Linux Kernel module information with modinfo command

Do not append a .ko extension to the end of the Kernel module name. Because Kernel module names do not have extensions, but their corresponding files do.

Display certain details of Kernel modules

When you run modinfo without any options, it displays a whole of lot information about the given kernel module. You can narrow down the result by displaying only specific fields such as author, description, license, parm, depends, and alias. The following commands displays the details of each field of the 88XXau module.

1. Display Kernel module author (vendor)

To view who wrote a Kernel module, use author flag.

$ modinfo -F author 88XXau
Realtek Semiconductor Corp.

2. Display Kernel module description

To print the description of a Kernel module, use description flag.

$ modinfo -F description 88XXau
Realtek Wireless Lan Driver

3. Display Kernel module license

Knowing the license of a Kernel module could be useful when you want to know whether the firmware and drivers are open or closed source. Some Linux distributions may include non-free drivers by default. You can verify if a device drive is free or non-free by checking the license attached to it.

$ modinfo -F license 88XXau

Most of Kernel modules are licensed under GPL (GNU Public License). A few modules may have dual license, for example BSD and GPL.

$ modinfo -F license zram

4. Display Kernel module parameters

To view the parameters of a Kernel module, run:

$ modinfo -F parm 88XXau
rtw_wireless_mode: (int)
rtw_monitor_overwrite_seqnum:Overwrite the sequence number of injected frames (int)
rtw_monitor_retransmit:Retransmit injected frames (int)
rtw_monitor_disable_1m:Disable default 1Mbps rate for monitor injected frames (int)
rtw_ips_mode:The default IPS mode (int)
rtw_lps_level:The default LPS level (int)

5. Display Kernel modules dependencies

To view dependencies of a Kernel module, run:

$ modinfo -F depends 88XXau

You can also use -a/--author, -d/--description, -l/--license, -p/--parameters flags to display the speicific details of Kernel modules. These are just the shortcuts for the --field flag's author, description, license, and parm. For instance, you can use -l or --license flag to view a Kernel module's license.

$ modinfo -l kvm


$ modinfo --license kvm

The above commands are equaivalent to the following command:

$ modinfo -F license kvm

For more details about modinfo command, look into its man pages.

$ man modinfo

Hope this helps.

Related read:

1 comment

Jalal May 13, 2021 - 1:34 pm

Very useful article
Thanks a lot


Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More