System and processes

The lsmod command

Lists the kernel modules loaded right now and who uses them.

Syntax

lsmod [opciones]Try it in the terminal →

Most useful options

-sSends errors to syslog instead of standard error
-vPrints messages about what the program is doing. Normally it prints only when something fails
-VShows the version and exits
-hShows the help and exits

Copy-ready examples

$ lsmodmodules loaded right now, with their size and the Used by column.
$ lsmod | grep -i usbfilters the modules related to USB.
$ lsmod | wc -lcounts the lines of the output, header included.
$ lsmod | grep '^ext4'checks whether the ext4 module is loaded and how many modules depend on it.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
bash: lsmod: command not foundlsmod comes in the kmod package, which is missing from minimal images and containers.Install it with sudo apt install kmod on Debian or Ubuntu.

Typical mistakes

  • It only shows what is loaded at this moment: an installed module that is not loaded does not appear.
  • The Used by column gives a use count and names the modules that depend on this one. A use can also come from a process or an open device, which is not named.
  • Modules compiled into the kernel do not appear in the list, even though they work.

Differences from similar commands

  • modprobe: Loads and unloads modules. lsmod only lists them.
  • modinfo: Shows the record of one specific module: file, description and dependencies. lsmod shows the ones loaded right now.
  • cat: With cat /proc/modules you see the same content unformatted, which is where lsmod gets its data.

FAQ

Can I unload a module that has dependents in Used by?

Not while those modules are loaded. First unload the ones that use it, then the module.

How do I see a module's record?

With modinfo name: file, description and dependencies.

Is it the same as lspci?

No. lsmod lists loaded kernel modules; lspci lists the PCI devices in the machine.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course