LinuxCommandLibrary

lsmod

List loaded kernel modules

TLDR

List all currently loaded kernel modules

$ lsmod
copy

SYNOPSIS

lsmod

DESCRIPTION

The lsmod command is a utility used in Linux to display the status of currently loaded kernel modules.

It provides a clear, human-readable list of all modules that are presently active in the kernel, along with their size, usage count, and a list of other modules that depend on them.

This information is crucial for system administrators and developers to understand the current configuration of the kernel, diagnose issues, or verify that specific hardware drivers or kernel features are loaded and operational.

The data presented by lsmod is directly sourced from the /proc/modules file, which is a virtual file system entry maintained by the kernel itself, providing real-time information about its loaded components.

CAVEATS

The lsmod command only displays modules that are currently loaded into the kernel's memory. It does not list all available modules on the system or modules that might be compiled into the kernel directly.

Its output is primarily designed for human readability, though it can be parsed by scripts.

The command relies on the existence and accessibility of the /proc/modules file, which provides the underlying data.

While generally robust, inconsistencies or corruption in this virtual file could impact lsmod's operation.

OUTPUT FORMAT

The output of lsmod typically consists of several columns:
Module: The name of the kernel module.
Size: The memory size, in bytes, that the module occupies in the kernel.
Used by: The number of other modules that are currently using this module. A value of 0 means no other modules are directly dependent on it.
Used by (list): A comma-separated list of other modules that depend on this specific module. If the 'Used by' count is 0, this column will be empty.

DATA SOURCE

The information displayed by lsmod is derived directly from the /proc/modules virtual file. This file is a kernel-maintained interface that provides a textual representation of all currently loaded kernel modules and their attributes. lsmod simply parses and formats the contents of this file for user-friendly display.

HISTORY

The concept of dynamically loadable kernel modules has been a fundamental part of the Linux kernel's design since its early versions, allowing for a more flexible and modular kernel.

The lsmod command is part of the module-init-tools (or historically modutils) package, which provides a suite of utilities for managing Linux kernel modules.

Over time, as the kernel evolved and module management became more sophisticated (e.g., handling dependencies, aliases, and blacklisting), lsmod remained a simple, essential tool for quickly inspecting the current state of loaded modules. Its core functionality of reading /proc/modules has remained consistent, reflecting the stable interface provided by the kernel.

SEE ALSO

modprobe(8), insmod(8), rmmod(8), modinfo(8), depmod(8), modules.conf(5)

Copied to clipboard