Intermediate LevelLinux Commands & SysAdmin
How do lsmod, modprobe, and insmod manage dynamic Linux kernel modules?
❓ Interview Prompt: Explain Linux kernel modules (.ko files), lsmod (list modules), modprobe (load with dependencies), rmmod, and /etc/modules-load.d/.
Linux kernel modules ('.ko' files) dynamically extend kernel functionality (device drivers, filesystems, network protocols) without rebooting the system:
•
'lsmod': Lists currently loaded kernel modules.
•
'modprobe <module>': Automatically resolves dependencies and loads the target module into memory.
•
'modprobe -r <module>': Unloads module safely.
•
*'/etc/modules-load.d/.conf'**: Configures modules to load automatically during system boot.
Code Implementation Example
bash
# List loaded kernel modules matching 'wireguard'
lsmod | grep wireguard
# Dynamically load module with dependency resolution
sudo modprobe wireguard
# Configure module to load at boot
echo "wireguard" | sudo tee /etc/modules-load.d/wireguard.conf💡Inspecting and dynamically loading Linux kernel modules using modprobe.
🎯 Interview Key Takeaway
Use modprobe instead of insmod because modprobe automatically resolves and loads module dependencies.
#Kernel Modules#modprobe#lsmod#Kernel#Intermediate
Back to all Linux Commands & SysAdmin Questions→