What command do you use to view which kernel modules are currently running?
The correct answer and explanation is:
Correct Answer:
The command used to view which kernel modules are currently running is:
lsmod
Explanation (300 Words):
In Linux and other Unix-like operating systems, the kernel is the core of the system responsible for managing hardware and system resources. Kernel modules are pieces of code that can be loaded and unloaded into the kernel dynamically to extend its functionality, such as device drivers, file systems, and system calls.
The lsmod
command, short for “list modules”, is used to display the status of currently loaded kernel modules. It reads the contents of the /proc/modules
file and presents the data in a readable tabular format.
Example Output of lsmod
:
Module Size Used by
i915 252928 3
drm_kms_helper 184320 1 i915
intel_agp 20480 1 i915
- Module: Name of the kernel module.
- Size: Memory size of the module in bytes.
- Used by: Number of instances using the module, often showing dependencies.
Why It’s Useful:
- Troubleshooting: Helps system administrators identify if a necessary driver or module is loaded.
- Performance: Prevents unnecessary modules from running, which can optimize system performance.
- Security: Ensures that only intended modules are active, reducing the attack surface.
Additional Related Commands:
modprobe <module_name>
– Loads a kernel module.rmmod <module_name>
– Removes a module.lsmod | grep <module_name>
– Checks if a specific module is loaded.modinfo <module_name>
– Displays detailed information about a module.
Using lsmod
is especially important when configuring or debugging hardware-related issues, ensuring that the correct drivers (modules) are being used by the kernel. It’s a vital tool in any Linux system administrator’s toolkit.