Lsmod Command in Linux (List Kernel Modules)

[ad_1]

lsmod is a command-line utility that displays information about the loaded Linux kernel modules.

Kernel modules #

The kernel is the core component of an operating system. It manages the system’s resources, and it is a bridge between your computer’s hardware and software.

The Linux kernel has a modular design. A kernel module, or often referred to as driver, is a piece of code that extends the kernel’s functionality. Modules are either compiled as loadable modules or built into the kernel. Loadable modules can be loaded and unloaded in the running kernel on request, without the need to reboot the system.

Generally, the modules are loaded on demand by udev (device manager). You can also manually load a module into the kernel using the modprobe
command, or automatically at boot time using /etc/modules or /etc/modules-load.d/*.conf files.

The kernel modules are stored in the /lib/modules/<kernel_version> directory. To find the version of the running kernel
, use the uname -r
command.

lsmod Command #

lsmod is a simple utility that does not accept any options or arguments. What the command does is that it reads /proc/modules and display the file contents in a nicely formatted list.

Run lsmod at the command line to find out what kernel modules are currently loaded:

lsmod

The command outputs information for each loaded kernel module on a new line:

Module                  Size  Used by
cmac                   16384  0
rfcomm                 81920  4
...
ahci                   40960  1
intel_lpss_pci         20480  0
i2c_i801               32768  0
libahci                32768  1 ahci
intel_lpss             16384  1 intel_lpss_pci
...

Each line has three columns:

  • Module – The first column shows the name of the module.
  • Size – The second column shows the size of the module in bytes.
  • Used by – The third column shows a number that indicates how many instances of the module are currently used. A value of zero means that the module is not used. The comma-separated list after the number shows what is using the module.

To find out whether a specific module is loaded, filter the output with grep
. For example to find whether the kvm module is loaded you would run:

lsmod | grep kvm
kvm_intel             278528  0
kvm                   651264  1 kvm_intel
irqbypass              16384  1 kvm

For detailed information about a module, use the modinfo command.

Conclusion #

The lsmod command shows a list of the currently loaded kernel modules.

Feel free to leave a comment if you have any questions.

[ad_2]

Source link

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.