The rmmod command in Linux removes a loaded module from the running kernel. Because the kernel has a modular design, you can load and unload drivers and features on demand, without rebooting or recompiling anything.
This guide covers how to use the rmmod command in Linux, when to use modprobe -r instead, and how to permanently prevent a module from loading at boot.
Kernel modules are stored in /lib/modules/<kernel_version>/. Each directory corresponds to a specific kernel version, which is why modules must be reinstalled after a kernel upgrade.
List all currently loaded modules with:
bashlsmod
To remove a loaded module:
bashsudo rmmod module_name
The command produces no output on success. To remove multiple modules in one step:
bashsudo rmmod module_name1 module_name2
On modern Linux systems, rmmod is part of the kmod package, which provides rmmod, modprobe, lsmod, insmod, and related tools through a single binary with symlinks.
Common options:
-v / --verbose — shows what the command is doing step by step-w / --wait — waits for the usage count to drop to zero before removing. Safer than -f when a module is still active-f / --force — forces removal even when the module is in use. Dangerous: the kernel may not clean up properly if another module is mid-operation, which can cause a crash-s / --syslog — sends error messages to syslog instead of standard errorrmmod removes only the module you name. If another loaded module depends on it, rmmod fails with an error.
modprobe -r is the preferred approach for most situations:
bashsudo modprobe -r module_name
It reads the full dependency tree and removes the named module plus any dependent modules that are no longer in use. Removal happens in the correct order, so no module is left in an inconsistent state.
Use rmmod only when you need precise control and you are certain the module has no loaded dependents.
Blacklisting is how you prevent a module from loading at the next boot. rmmod only removes the module for the current session — it loads again after a reboot unless you blacklist it.
Create a configuration file in /etc/modprobe.d/:
bashsudo nano /etc/modprobe.d/blacklist-custom.conf
Add one module name per line:
blacklist module_name
After saving, regenerate the initramfs to apply the blacklist at boot. On Debian and Ubuntu:
bashsudo update-initramfs -u
On RHEL, Rocky Linux, and AlmaLinux:
bashsudo dracut --force
The initramfs is a compressed filesystem loaded early in the boot process. Without regenerating it, a module already embedded in the current initramfs image can load before the blacklist takes effect.
Common errors:
Module is in use — check what depends on it with lsmod | grep module_name. The third column shows the usage count; the fourth lists dependent modules. Remove dependents first, or use modprobe -rModule is not currently loaded — verify the exact module name with lsmodOperation not permitted — run with sudoPrefer modprobe -r for everyday module removal since it handles dependencies automatically. Use rmmod when you need explicit control with no automatic dependency resolution. Leave a comment below if you run into any issues.
The free command in Linux gives you a quick summary of RAM and swap usage. It reads…
The diff command in Linux compares two text files line by line and shows the lines that…
DNS cache is a temporary database your OS and browser build as you browse. Each time you visit a website, the domain-to-IP mapping is saved locally, cutting out the round trip to a remote DNS server on repeat visits. Stale entries are the most common reason to flush the DNS cache: a server moves to a new IP, but your OS or browser still routes to the old address. This guide covers how to clear the DNS cache on Windows, Linux, and macOS, and how to flush the separate cache stored inside Chrome and Firefox. Flush DNS Cache on Windows The command is the same on Windows 10, Windows 11, and earlier supported releases. Open Command Prompt with administrator privileges. Type cmd in the Windows search bar, right-click Command Prompt, and select Run as…
Using a strong, unique password for every account is one of the most effective security…
Ubuntu locks the root account by default. New users often wonder what the root password…
Since Ubuntu 17.10, networking is configured with Netplan rather than the older /etc/network/interfaces file. You write a…