System and processes
The rmmod command
Unloads a kernel module from memory, such as a hardware driver. It requires root and only works if no process or other module is using it.
Most useful options
-wWaits until the module is no longer in use, instead of failing at once-vShows what it is doing-sSends the messages to the system log (syslog) instead of the screen-fForces the unload even if it is in use. It can crash the kernel: avoid itCopy-ready examples
$ lsmod | head -5modules loaded right now: name, size and how many use them.Example output
Module Size Used by vboxdrv 667648 0 snd_usb_audio 380928 2
$ sudo rmmod vboxdrvunloads the VirtualBox driver, if nothing uses it.$ sudo modprobe -r vboxdrvunloads the module and also the dependencies nobody else uses. It is usually safer than rmmod.$ modinfo vboxdrv | head -3what the module does before removing it: description, license and file.$ sudo rmmod -w usb_storagewaits until USB storage devices are no longer in use, then unloads it.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| rmmod: ERROR: Module vboxdrv is in use | Something uses it: an open program or another module that depends on it. List who uses it with lsmod, in the Used by column. | Close the program using it or unload the dependent modules first; modprobe -r can do it in one step. |
Typical mistakes
- rmmod does not unload dependencies: if another module uses yours, it fails. An unloaded module loads again if udev or the configuration asks for it.
- After unloading a module, the hardware it controlled may stop working until it is loaded again.
Differences from similar commands
Security
Forcing the removal of a driver in use can crash the kernel. And unloading security modules, such as auditing or firewall ones, lowers protection without any warning.
FAQ
Why does it come back after rmmod?
Because something loads it again: udev when it detects hardware, a service or a configuration line. To prevent it, add a blacklist entry in /etc/modprobe.d/.
Does rmmod uninstall the driver?
No. It only removes it from memory; the file stays in /lib/modules. To uninstall it completely, use the package manager.
How do I know if a module can be removed?
With lsmod: the Used by column must be 0. If it shows something, unload those modules first.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course