rmmod
Remove loadable kernel modules
TLDR
Remove a module from the kernel
Remove a module from the kernel and display verbose information
Remove a module from the kernel and send errors to syslog instead of stderr
Display help
Display version
SYNOPSIS
rmmod [-f] [-w] [-s] [-v] module [module...]
PARAMETERS
-f
Force removal. This option is dangerous and should be used with caution as it can cause system instability if dependencies are not handled correctly. Attempts to remove even if module is marked as unsafe.
-w
Wait until the module is no longer in use before attempting to unload it. This can be useful if a process is currently using the module.
-s
Send errors to syslog instead of stderr.
-v
Verbose mode. Prints more information about the removal process.
module
The name of the module to remove. The '.ko' extension is typically omitted.
DESCRIPTION
The `rmmod` command is used to remove (unload) a module from the Linux kernel. Modules are pieces of code that can be dynamically loaded and unloaded into the kernel, extending its functionality without requiring a reboot. rmmod is essentially a simplified front-end to the `delete_module` system call.
Using rmmod requires root privileges because it directly modifies the kernel's state. It is often used during system administration tasks such as troubleshooting hardware drivers, updating kernel functionality, or cleaning up unused modules to free up system resources. Before removing a module, ensure that no other modules are dependent on it. Removing a module with dependencies can lead to system instability or crashes.
Modern systems often use tools like modprobe -r which handles dependencies more gracefully by unloading dependent modules automatically. Using modprobe -r is recommended as it ensures that dependent modules are unloaded in the correct order.
CAVEATS
Forcing the removal of a module with -f can lead to kernel panics or other serious problems. Verify that no dependencies exist, or use `modprobe -r` instead, if dependencies management is needed.
MODULE DEPENDENCIES
It's crucial to check for module dependencies before using `rmmod`. The `lsmod` command shows which modules are loaded and which other modules they depend on. Trying to remove a module that's being used by another module will result in an error unless you use the `-f` option.
ALTERNATIVES
`modprobe -r module` is the recommended alternative to `rmmod` for most use cases because it automatically handles module dependencies and ensures that modules are unloaded in the correct order.
You can use it as a safer, more convenient way to remove modules.
HISTORY
The `rmmod` command has been a core part of the Linux kernel module management system since the early days of Linux. It provides a fundamental way to unload modules dynamically. Over time, `modprobe` has become the preferred tool due to its superior dependency handling capabilities. `rmmod` remains available for direct module manipulation, but its usage is less common in automated scripts.