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
- Kernel module inspection
- System troubleshooting
- Driver verification
- Module dependency checking
- 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
Check module status:
lsmod | grep module_name
Find dependencies:
lsmod | grep -w 'module'
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
- Loading modules
- Removing modules
- Dependency tracking
- Parameter setting
- Blacklisting
Best Practices
- Regular module checks
- Document dependencies
- Monitor module size
- Check module parameters
- Maintain security