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.
lsmod
sudo modprobe MODULE [PARAM=VALUE]...
sudo modprobe -r MODULE
modinfo MODULE
Try it
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.
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
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 nameormodinfo namefirst;modprobe -n -v nameshows the plan without doing it. - Autoloading: the kernel and
udevload most drivers automatically when hardware appears. You rarely runmodprobeby hand except for features likeoverlay,br_netfilterorloop. - 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 exampleoptions usb-storage quirks=...orblacklist nouveau. - Blacklisting stops automatic loading by alias only;
install MODULE /bin/falseblocks even explicitmodprobe. - Use count: a module with a non-zero count in
Used bycannot 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=1in/proc/syslocks module loading until reboot.
Related
uname,lspciandlsusb,dmesg,sudo- Lessons: Boot and kernel, Hardening