Linux command
lsmod 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
List all loaded kernel modules
lsmod
Filter by name
lsmod | grep [nvidia]
Sort modules by size
lsmod | sort -k 2 -n -r
Count loaded modules
lsmod | tail -n +2 | wc -l
Find who is using a module
lsmod | awk '$1 == "[btusb]" { print $4 }'
说明
lsmod is a trivial program that nicely formats the contents of `/proc/modules`, showing which loadable kernel modules are currently in memory. It takes no arguments (apart from `--help` / `--version` on some distros). The output has one module per line, with three columns: - Module — name of the module - Size — memory footprint in bytes - Used by — reference count followed by a comma-separated list of modules or subsystems that depend on it A reference count greater than zero means the module is in use and cannot simply be `rmmod`-ed without unloading its dependents first.
FAQ
What is the lsmod command used for?
lsmod is a trivial program that nicely formats the contents of `/proc/modules`, showing which loadable kernel modules are currently in memory. It takes no arguments (apart from `--help` / `--version` on some distros). The output has one module per line, with three columns: - Module — name of the module - Size — memory footprint in bytes - Used by — reference count followed by a comma-separated list of modules or subsystems that depend on it A reference count greater than zero means the module is in use and cannot simply be `rmmod`-ed without unloading its dependents first.
How do I run a basic lsmod example?
Run `lsmod` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more lsmod examples?
This page includes 5 examples for lsmod, plus related commands for nearby Linux tasks.