Oct 21, 2023 3 min read

Lsmod Command in Linux (List Kernel Modules)

Use lsmod command in Linux with our step-by-step tutorial. The lsmod command is used to display the currently loaded kernel modules.

Lsmod Command in Linux
Table of Contents

Introduction

Before we discuss lsmod Command in Linux (List Kernel Modules), let's first understand-What is lsmod Command ?

The lsmod command in Linux is used to display the currently loaded kernel modules (also known as device drivers). Kernel modules are pieces of code that provide additional functionality to the kernel, enabling support for various hardware devices or implementing specific features.

With lsmod, users can obtain a list of active modules in the Linux kernel, along with information such as the module name, size, and the number of times it is currently being used.

You will go through the concepts of lsmod command in this tutorial. We will also address a few FAQs on lsmod Command in Linux (List Kernel Modules).

Kernel Modules

An operating system's kernel is its most important component. It is a bridge between your computer's hardware and software, and it manages the system's resources.

The Linux kernel is built in a modular fashion. A kernel module, often known as a driver, is a piece of software that extends the capabilities of the kernel. Modules are either incorporated into the kernel or compiled as loadable modules. Loadable modules can be loaded and unloaded in the running kernel without requiring a system reboot.

udev loads the modules on-demand in most cases (device manager). You can also use the modprobe command to manually load a module into the kernel, or use the /etc/modules or /etc/modules-load.d/*.conf files to do so automatically at boot time.

The kernel modules are located in the path /lib/modules/kernel <version>. Use the uname -r command to determine the current kernel version.

lsmod Command

lsmod is a simple utility that doesn't take any arguments or accept any options. The command reads /proc/modules and displays the contents of the file in a nicely organized list.

To see what kernel modules are presently loaded, type lsmod at the command prompt:

lsmod

Each loaded kernel module's information is printed on a separate line by the command:

Output

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
...

There are three columns on each line:

  • Module - The name of the module appears in the first column.
  • Size - The second column displays the module's size in bytes.
  • Use by - The third column displays a number indicating how many instances of the module are currently in use. The module is not used if the value is zero. After the number, a comma-separated list of what is using the module appears.

Use grep to filter the output to see if a specific module is loaded. For instance, to see if the kvm module is loaded, you might type:

lsmod | grep kvm
Output

kvm_intel             278528  0
kvm                   651264  1 kvm_intel
irqbypass              16384  1 kvm

Use the modinfo command to get detailed information about a module.

FAQs on lsmod Command in linux

How does the lsmod command work?

lsmod retrieves information from the /proc/modules file, which contains details about the currently loaded kernel modules.

How do I use the lsmod command to list kernel modules?

To use lsmod, simply execute the lsmod command without any arguments in a terminal. It will display a list of currently loaded kernel modules, along with relevant information.

What kind of information does lsmod provide about each module?

lsmod displays information about each loaded kernel module, including the module name, size, the number of times it is being used (used by other modules), and a list of other modules that depend on it.

Can I filter lsmod output to display specific modules?

Yes, you can use tools like grep to filter lsmod output and display specific modules based on criteria such as the module name or other relevant information.

Can lsmod show information about modules that are not currently loaded?

No, the lsmod command only shows information about currently loaded kernel modules. It does not provide information about modules that are available but not currently in use.

Can lsmod help with troubleshooting hardware-related issues?

Yes, lsmod can be useful for troubleshooting hardware-related problems as it provides insight into which kernel modules are currently loaded. Users can identify if the required module for a specific hardware device is loaded or if any conflicting modules exist.

Can I unload a kernel module using lsmod?

No, lsmod only lists the currently loaded kernel modules. To unload a module from the kernel, you need to use the rmmod command followed by the module name.

Conclusion

The lsmod command displays a list of the kernel modules that are currently loaded.

If you have any queries, please leave a comment below and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.