Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท System Information

Linux lsmod and modprobe commands

Reference for lsmod, modprobe, modinfo and rmmod: list loaded kernel modules, load and unload them with dependencies, pass parameters and blacklist drivers.

A kernel module is a piece of kernel code (usually a driver or a file system) that can be loaded and unloaded while the system runs. lsmod lists the modules that are loaded now; modprobe loads or removes a module together with the modules it depends on; modinfo describes one; rmmod and insmod are the low-level pieces.

Loading and unloading modules needs root, and a container or sandbox shares the host kernel, so those commands are read-only examples on this site. The listing itself is just a formatted view of /proc/modules, which you can often read without special rights.

Terminal
lsmod
sudo modprobe MODULE [PARAM=VALUE]...
sudo modprobe -r MODULE
modinfo MODULE

Try it

Bash Reading the module list from /proc

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Read-only: what the commands look like

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
lsmod
modprobe [-v] [-n] MODULE [SYMBOL=VALUE]...
modprobe -r MODULE...
modinfo [-F FIELD] MODULE
insmod FILE.ko         # load one file, no dependency handling
rmmod MODULE           # unload one module, no dependency handling
Command / option Description
lsmod Table of loaded modules: name, memory size, use count and the modules that use it.
modprobe MODULE Load MODULE after loading everything it depends on (from modules.dep).
modprobe -r MODULE Unload MODULE and dependencies that are no longer used.
modprobe -n -v MODULE Dry run: show what would happen.
modprobe -c Print the merged configuration.
modinfo MODULE Show file name, description, author, license, parameters and dependencies (-F depends, -p for parameters).
insmod, rmmod Manual load/unload of a single file or module.

Errors: Operation not permitted without root; Module X not found in directory /lib/modules/... when the module is not installed for the running kernel; Module X is in use when something still needs it; Required key not available when Secure Boot rejects an unsigned module.

Usage notes

  • Check, then load. lsmod | grep -w name or modinfo name first; modprobe -n -v name shows the plan without doing it.
  • Autoloading: the kernel and udev load most drivers automatically when hardware appears. You rarely run modprobe by hand except for features like overlay, br_netfilter or loop.
  • Persistent loading: list module names (one per line) in a file under /etc/modules-load.d/. Parameters and blacklists go in /etc/modprobe.d/*.conf, for example options usb-storage quirks=... or blacklist nouveau.
  • Blacklisting stops automatic loading by alias only; install MODULE /bin/false blocks even explicit modprobe.
  • Use count: a module with a non-zero count in Used by cannot be removed. Unloading hardware drivers may hang the device or the system.
  • Built-in is invisible: features compiled into the kernel do not appear in lsmod. Look in /lib/modules/$(uname -r)/modules.builtin.
  • Kernel version matters: modules are built for one exact kernel (uname -r). A kernel update without matching modules breaks loading.
  • Security: loading modules is a root-level, kernel-wide action. Containers should not be given the capability; kernel.modules_disabled=1 in /proc/sys locks module loading until reboot.