The lsmod command in Linux lists all currently loaded kernel modules. It reads /proc/modules — a virtual file maintained by the kernel — and formats the output into three labeled columns.
lsmod takes no options or arguments.
Run it without any flags:
bashlsmod
The output looks like this:
Module Size Used bykvm_intel 278528 0kvm 651264 1 kvm_intelirqbypass 16384 1 kvmahci 40960 1libahci 32768 1 ahci
Each row has three columns:
A “Used by” count of 0 means the module is loaded but not actively in use and has no dependents. It is a candidate for removal.
The “Used by” column is the key field for safe module management.
In the output above, kvm_intel depends on kvm — its name appears in kvm‘s dependency list. To remove kvm, you must first run modprobe -r kvm_intel. Attempting to remove kvm while kvm_intel is loaded fails with a “module is in use” error.
Modules reach the system in three ways: automatically by udev when hardware is detected, manually with modprobe, or at boot via /etc/modules or /etc/modules-load.d/*.conf. Modules compiled directly into the kernel at build time are called built-in modules and do not appear in lsmod output at all.
For scripts that need raw module data, read the source file directly:
bashcat /proc/modules
To check whether a specific module is loaded:
bashlsmod | grep kvm
To list modules whose “Used by” count is 0:
bashlsmod | awk '$3 == 0'
$3 targets the third column in each row. A zero count means the module can be unloaded without breaking anything that depends on it.
To get detailed information about a specific module before acting on it:
bashmodinfo kvm
The output includes the file path, license, author, description, and configurable parameters. The file path shows the kernel version the module belongs to. Modules live in /lib/modules/<kernel_version>/ and are version-specific — a module built for one kernel will not load on another.
To unload a module and its dependencies:
bashsudo modprobe -r kvm_intel
Only run modprobe -r after confirming the “Used by” count is 0 and no service or device depends on the module.
Start with lsmod to see what is loaded, use grep to look up a specific module, awk '$3 == 0' to find removal candidates, and modinfo to review details before making changes. Leave a comment below if you run into any issues.