List Loaded Kernel Module Information using Lsmod Command

lsmod is a command-line tool used to display kernel modules that are currently loaded. Kernel modules are pieces of code that can be loaded and unloaded into the kernel upon request. It will extend the kernel functionality at runtime. The most common functionalities of kernel modules are device drives to support new hardware, filesystem support, system calls, and more.

Kernel modules are loaded either automatically ( by udev) or manually. You can manually load modules using the modprobe command. Modules explicitly listed in /etc/modules-load.d/<program>.conf to load on boot.kmod package provides tools to manually handle kernel modules.

The kernel modules are kept in the /lib/modules/<kernel_version> directory. Use uname -r command to find the kernel version.

lsmod Command

lsmod command nicely prints the contents of the /proc/modules. To list the currently loaded kernel modules, type:

$ lsmod

Output:

Module                  Size  Used by
 vboxvideo              49152  0
 rfkill                 28672  3
 intel_rapl_msr         20480  0
 intel_rapl_common      28672  1 intel_rapl_msr
 intel_pmc_core_pltdrv    16384  0
 intel_pmc_core         45056  0
 intel_powerclamp       20480  0
 ghash_clmulni_intel    16384  0
 joydev                 28672  0
 hid_generic            16384  0
 snd_intel8x0           49152  2
 snd_ac97_codec        180224  1 snd_intel8x0
 aesni_intel           368640  0
 ac97_bus               16384  1 snd_ac97_codec
 usbhid                 65536  0
 hid                   147456  2 usbhid,hid_generic
 libaes                 16384  1 aesni_intel
 crypto_simd            16384  1 aesni_intel
 snd_pcm               135168  2 snd_intel8x0,snd_ac97_codec
 snd_timer              49152  1 snd_pcm
 cryptd                 24576  2 crypto_simd,ghash_clmulni_intel

The output shows three columns: Module, Size, and Used by.

1st column - names of currently loaded modules.
2nd column - the amount of memory per module in kilobytes.
3rd column - shows the total use count, and optionally the names of modules that are dependent on a particular module.

To search specific modules from the lsmod output, use the grep command to filter.

For example:

$ lsmod | grep e1000

Output:

e1000                 155648  0

Use modinfo command to get more information about kernel modules such as the absolute path to the .ko kernel object file, depends, author, description, and license.

$ sudo modinfo e1000

Conclusion

In this tutorial, we learned lsmod command which lists the currently loaded kernel modules in Linux.

Thanks for reading, please lets us know your suggestions in the below comment section.

Leave a Comment