📝 Module management of Linux system (12 MCQs)
Controlling Installation and Removal of Kernel Modules
Linux module management covers loading, listing, configuring, dependency handling, and unloading kernel modules. Administrators use tools such as modprobe, insmod, rmmod, and lsmod to manage loadable functionality. The kernel verifies module compatibility and controls registration, while user-space tools locate module files and interpret dependency information maintained for the running kernel.
Why Dependencies and Configuration Must Be Managed
A driver or subsystem module may require other modules before it can operate. Loading components in the wrong order or removing a module still in use can cause failure. Module management tools automate dependency resolution and apply configuration rules, reducing the need for administrators to load every component manually.
Using modprobe and Related Management Tools
The administrator invokes modprobe with a module name. It consults dependency metadata and configuration files, loads required components, and inserts the requested module. lsmod displays loaded modules, while modinfo reports module information. rmmod requests removal, provided active references and dependency conditions permit unloading.
Example of Loading a Dependent Driver
A network adapter driver requires a supporting module before it can initialise. An administrator uses modprobe to load the driver by name. The tool resolves recorded dependencies and loads the required components first. lsmod can then display the modules currently present in the running kernel.
Automation, Reliability and Administrative Caution
Automatic dependency handling simplifies device setup and supports dynamic hardware discovery. Incorrect blacklist rules or incompatible modules can prevent devices from working, while forced removal may destabilise the system. Administrators should inspect module information, use trusted packages, and ensure a module is not actively required before unloading it.
Misconceptions About Linux Module Tools
'insmod automatically resolves every dependency' is false because it generally inserts a specified module without modprobe's dependency handling. 'lsmod loads missing modules' is incorrect because it reports current module status. 'rmmod safely removes every requested module' ignores active use and dependency restrictions.
Exam Focus: Linux Module Commands and Dependencies
Distinguish modprobe, insmod, rmmod, lsmod, and modinfo by their functions. Trace loading when one module depends on another and explain why removal may be rejected. Questions may examine configuration files, blacklisting, module metadata, and the importance of compatibility with the running kernel.
Key Terms of Module Management
- modprobe - Loads modules with dependency handling.
- insmod - Inserts a specified module file.
- rmmod - Requests removal of a module.
- lsmod - Lists currently loaded modules.
- modinfo - Displays module metadata.
📝 All Module management of Linux system MCQs
Q1. A system administrator wants to add support for a new USB network adapter without rebooting. Which command sequence correctly loads the driver module and verifies it is active?
📖 Explanation: The correct sequence is A because modprobe automatically loads the module and resolves dependencies, then lsmod lists loaded modules, confirming the driver is active. insmod requires the exact .ko file and does not handle dependencies, making B less reliable. rmmod removes a module, so C would unload before loading. modprobe -r removes, not loads, so D is incorrect. This mirrors real‑world admin tasks of adding hardware on‑the‑fly.
Q2. During development, a programmer compiles a kernel module named mydriver.ko but receives an “invalid module format” error when loading it. Which step is most likely missing?
📖 Explanation: Running depmod updates the module dependency database, allowing the kernel to recognize the new module format; missing this step often triggers “invalid module format.” Signing the module (B) is required only for Secure Boot, not for format errors. Rebuilding kernel headers (C) is unnecessary if they already match. Compressing the file (D) would not cause this error. Understanding this helps developers troubleshoot module load failures.
Q3. A Linux distribution ships with a minimal kernel lacking many drivers. A user needs a filesystem driver for XFS. Which approach best utilizes kernel modules?
📖 Explanation: Loading the XFS module with modprobe leverages the modular design, allowing the filesystem support to be added without rebuilding the whole kernel. Recompiling (A) defeats the purpose of modularity and is time‑consuming. A userspace FUSE driver (C) provides limited functionality and is not the standard XFS implementation. Upgrading the kernel (D) may work but isn’t necessary if the module exists. This reflects typical scenarios where admins add filesystem support on demand.
Q4. A security analyst discovers that a rogue kernel module named backdoor.ko has been loaded. Which command can both list loaded modules and show the memory address where each resides, aiding forensic analysis?
📖 Explanation: The /proc/modules file lists each loaded module along with its size and memory address, providing essential forensic data. lsmod gives similar info but omits addresses, making A less detailed. modinfo shows static module metadata, not runtime locations, so C is insufficient. dmesg may contain load messages but not reliable address data, thus D is not optimal. Knowing the memory address helps trace malicious activity in the kernel.
Q5. When building a kernel module, a developer uses the makefile variable EXTRA_CFLAGS to add -DCONFIG_DEBUG. What effect does this have on the compiled module?
📖 Explanation: Adding -DCONFIG_DEBUG defines the CONFIG_DEBUG macro, allowing conditional compilation of debug statements within the module source. It does not alter licensing (B), load priority (C), or kernel version compatibility (D). This technique is common for developers who need verbose output during testing while keeping the same binary interface for production.
Q6. A sysadmin needs to temporarily disable a loaded module named firewire_core without rebooting, then re‑enable it later. Which sequence accomplishes this safely?
📖 Explanation: Using modprobe with -r removes the module while handling dependencies, and invoking modprobe again reloads it, preserving proper initialization. rmmod/insmod ( B) bypasses dependency handling and can fail. Writing to sysfs parameters (C) only works if the module exposes such a toggle, which is uncommon. “unload/load” (D) are not actual commands. This reflects real tasks of temporarily disabling hardware support.
Q7. Why does the Linux kernel allow loadable modules instead of requiring all drivers to be compiled into the kernel?
📖 Explanation: Loadable modules keep the base kernel small and let administrators add only the needed drivers, conserving memory and simplifying updates. Licensing (B) is unrelated; many compiled‑in drivers are GPL. Preventing modification (C) is opposite to the kernel’s open nature. While modularity can affect boot time, the primary goal is flexibility, not just speed.
Q8. How does the kernel ensure that a newly loaded module does not conflict with existing symbols or resources?
📖 Explanation: The kernel’s symbol versioning matches the module’s exported symbols with those already present, preventing mismatched or duplicate definitions. Checksums (A) verify integrity but not compatibility. Signing (C) enforces security, not conflict resolution. Namespaces (D) are not used for kernel symbols; all modules share the same global namespace. Understanding this mechanism helps developers avoid runtime errors when adding new modules.
Q9. What is the primary security implication of loading a third‑party kernel module on a production server?
📖 Explanation: A third‑party module runs in kernel space with full system privileges, so malicious code can compromise the entire system. Performance improvements (B) are not guaranteed. GPL compliance (C) concerns licensing, not security. Loading a module does not affect SELinux status (D). Recognizing this risk is crucial for administrators managing production environments.
Q10. In the context of kernel modules, what does the term “dependency” refer to?
📖 Explanation: Dependencies are other kernel modules that provide symbols or functionality needed by the loading module; they must be present before the new module can initialize. It is not about kernel config options (A), shared user‑space libraries (B), or specific hardware (D). Knowing dependencies prevents load failures and ensures proper module order.
Q11. Why might a developer choose to distribute a driver as a kernel module rather than integrating it into the mainline kernel source?
📖 Explanation: Distributing as a module lets users load the driver on demand, keeping the base kernel lean and simplifying updates. Avoiding GPL (A) is not a valid reason; modules are also GPL‑licensed. Modules do not inherently run faster (C); performance is comparable. Kernel version checks apply to both modules and built‑in code, so D is inaccurate.
Q12. What command displays detailed information, including author and license, about a loaded kernel module named snd_hda_intel?
📖 Explanation: The modinfo command retrieves metadata such as author, description, and license for a given module, whether loaded or not. lsmod only lists module names, sizes, and usage counts (B). cat /proc/modules provides similar limited info (C). dmesg shows kernel messages, which may not contain the specific metadata (D). This knowledge helps users verify module provenance.