Rmmod Command in Linux

The rmmod command removes (unloads) a module from the Linux kernel. Kernel modules are pieces of code that extend the kernel’s functionality without requiring a system reboot.
This guide covers how to use the rmmod command, its options, and when to use modprobe -r instead.
Understanding Kernel Modules
The Linux kernel has a modular design. A kernel module, often referred to as a driver, is code that can be loaded and unloaded into the kernel on demand. This allows you to extend hardware support or add functionality without rebuilding the kernel or rebooting the system.
Kernel modules are stored in the /lib/modules/<kernel_version> directory. You can list all currently loaded modules with the lsmod
command:
lsmodBasic Syntax
The general syntax for the rmmod command is:
rmmod [OPTIONS] MODULE_NAME...On modern Linux systems, rmmod is part of kmod, a binary that implements multiple programs for managing kernel modules.
Only users with root or sudo privileges can remove modules.
Removing a Kernel Module
To remove a loaded module, run rmmod followed by the module name:
sudo rmmod module_nameThe command produces no output on success. If the module cannot be removed, you will see an error message.
You can remove multiple modules in a single command:
sudo rmmod module_name1 module_name2Common Options
The rmmod command accepts the following options:
-v,--verbose— Display detailed information about what the command is doing.-f,--force— Force removal of the module, even if it is in use or was not designed to be removed. This option is dangerous and can crash your system.-s,--syslog— Send error messages to syslog instead of standard error.-w,--wait— Wait for the module to become unused before removing it.
To see verbose output when removing a module:
sudo rmmod -v module_namermmod vs modprobe -r
While rmmod removes a single module, modprobe -r
is the preferred method for removing modules. The key difference is that modprobe -r also removes dependent modules that are no longer needed:
sudo modprobe -r module_nameWe recommend using modprobe -r for most situations, as it handles module dependencies automatically.
Blacklisting a Module
When you remove a module with rmmod, it will be loaded again on the next system boot. To permanently prevent a module from loading, you need to blacklist it.
Create a configuration file in /etc/modprobe.d/:
blacklist module_nameYou can add multiple modules to the same file, one per line, or create separate .conf files for each module.
After adding a module to the blacklist, regenerate the initramfs:
sudo update-initramfs -uOn RHEL-based systems, use:
sudo dracut --forceQuick Reference
| Task | Command |
|---|---|
| Remove a module | sudo rmmod module_name |
| Remove with verbose output | sudo rmmod -v module_name |
| Force remove (dangerous) | sudo rmmod -f module_name |
| Remove multiple modules | sudo rmmod mod1 mod2 |
| Remove with dependencies | sudo modprobe -r module_name |
| List loaded modules | lsmod |
| Check if module is loaded | lsmod | grep module_name |
| Blacklist a module | Add blacklist module_name to /etc/modprobe.d/blacklist.conf |
Troubleshooting
Module is in use
If you see an error like rmmod: ERROR: Module module_name is in use, another module or process depends on it. Use lsmod to check what is using the module:
lsmod | grep module_nameThe third column shows the usage count, and the fourth column lists dependent modules. Remove the dependent modules first, or use modprobe -r to handle dependencies automatically.
Module not found
If you receive rmmod: ERROR: Module module_name is not currently loaded, the module is not loaded. Verify the module name with lsmod.
Operation not permitted
This error occurs when you run rmmod without root privileges. Use sudo before the command.
Module removal causes system instability
Never force-remove modules that are in use. If you used -f and the system becomes unstable, reboot to restore normal operation.
FAQ
What is the difference between rmmod and modprobe -r?rmmod removes only the specified module, while modprobe -r removes the module and any unused dependent modules. Use modprobe -r for safer module removal.
Can I remove a module that is in use?
You can force removal with rmmod -f, but this is dangerous and can crash your system. It is better to stop the processes using the module first.
How do I know which modules are safe to remove?
Use lsmod to see loaded modules and their dependencies. Modules with a usage count of 0 and no dependent modules are generally safe to remove. Avoid removing critical system modules.
Will the module stay unloaded after reboot?
No. The module will load again on the next boot unless you blacklist it in /etc/modprobe.d/.
How do I reload a module after removing it?
Use modprobe module_name to load a module. This is preferred over insmod because it handles dependencies automatically.
Conclusion
The rmmod command removes kernel modules from a running Linux system. For most use cases, we recommend using modprobe -r instead, as it handles module dependencies automatically.
If you have any questions, feel free to leave a comment below.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page