What Is the lsmod Command in Linux?
This article provides a comprehensive overview of the
lsmod command in the Linux operating system, explaining its
primary purpose, how it functions, and how to interpret its output. You
will learn how system administrators use lsmod to inspect
currently loaded kernel modules, troubleshoot hardware driver issues,
and analyze module dependencies to maintain system stability.
The lsmod (list modules) command is a fundamental Linux
utility used to display the status of modules currently loaded into the
Linux kernel. The Linux kernel uses Loadable Kernel Modules (LKMs) to
extend its functionality on the fly—such as adding support for hardware
devices, file systems, or network protocols—without requiring a full
system reboot. The lsmod command provides an immediate
snapshot of these active components.
Technically, lsmod does not perform complex queries on
its own. Instead, it accesses the /proc/modules virtual
file, parses its raw contents, and presents the data in a clean,
human-readable table.
When you run lsmod in a terminal, the output is
organized into three distinct columns:
- Module: The name of the currently loaded kernel module.
- Size: The amount of memory occupied by the module in RAM, displayed in bytes.
- Used by: This column displays two key pieces of information: a count of how many processes or other modules are currently using it, followed by a comma-separated list of the specific dependent modules. If a module shows a count of zero and no listed dependents, it is currently unused and can typically be safely unloaded.
The primary use cases for the lsmod command include:
- Hardware Verification: Confirming whether the operating system has detected and loaded the necessary drivers for peripherals like Wi-Fi adapters, sound cards, or dedicated GPUs.
- Filtering Module Data: Combining
lsmodwith standard text-processing utilities to locate specific drivers. For example, runninglsmod | grep nouveauallows you to quickly check if the open-source NVIDIA graphics driver is active. - Troubleshooting Dependencies: Determining which modules are preventing an unwanted driver from being removed, since a module cannot be unloaded if its "Used by" count is greater than zero.
While lsmod is dedicated strictly to viewing active
modules, it works alongside utilities like modprobe (used
to load and unload modules along with their dependencies) and
modinfo (used to view detailed metadata about a specific
module). Together, these tools form the core toolkit for Linux kernel
module management.