lsmod

Overview

The lsmod command shows the status of modules in the Linux kernel. It displays information about all loaded kernel modules.

Syntax

lsmod

Common Options

Note: lsmod doesn’t typically take options as it simply shows the contents of /proc/modules in a formatted way.

Key Use Cases

  1. Kernel module inspection
  2. System troubleshooting
  3. Driver verification
  4. Module dependency checking
  5. System monitoring

Examples with Explanations

Example 1: List All Modules

lsmod

Show all loaded kernel modules

Example 2: Filter Output

lsmod | grep video

Show only video-related modules

Example 3: Sort by Size

lsmod | sort -k 2 -n

List modules sorted by size

Understanding Output

Columns explained: - Module: Name of module - Size: Memory size in bytes - Used: Reference count - Used by: List of dependent modules

Example output:

Module                  Size  Used by
bluetooth             557056  23
rfcomm                 81920  4
bnep                   24576  2

Common Usage Patterns

  1. Check module status:

    lsmod | grep module_name
  2. Find dependencies:

    lsmod | grep -w 'module'
  3. Module size analysis:

    lsmod | sort -k 2 -nr | head

Performance Analysis

  • Fast execution
  • Reads from /proc
  • Minimal system impact
  • Real-time information
  • No disk I/O required

Additional Resources

Module Management

  1. Loading modules
  2. Removing modules
  3. Dependency tracking
  4. Parameter setting
  5. Blacklisting

Best Practices

  1. Regular module checks
  2. Document dependencies
  3. Monitor module size
  4. Check module parameters
  5. Maintain security