Open In App

rmmod command in Linux with Examples

Last Updated : 10 Oct, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The rmmod command in Linux is used to remove or unload a module from the kernel. Modules are pieces of code that can be dynamically loaded into the Linux kernel to extend its functionality, such as drivers for hardware devices. When a module is no longer needed, it can be removed using rmmod.

Although many users prefer to use the modprobe -r command for removing modules, rmmod directly unloads a module from the kernel.

Syntax

rmmod [options] [modulename]

where,

  • modulename: The name of the module to be removed.
  • [options]: Various optional flags that modify how rmmod behaves.

Basic Example

rmmod bluetooth

Key Options for the rmmod Command

1. rmmod command with help option

It will print the general syntax of the rmmod along with the various options that can be used with the rmmod command as well as gives a brief description about each option.

Example:

rmmod command with help option

2. rmmod -v

This option prints messages about what the program is being doing. Usually rmmod only prints messages only if something went wrong.

Example:

rmmod -v bluetooth

rmmod -v

3. rmmod -f

This option can be extremely dangerous. It takes no effect unless CONFIG_MODULE_FORCE_UNLOAD is being set when the kernel was compiled. With this option, you can remove the specified modules which are being used, or which are not being designed to be removed or have been marked as not safe.

Example:

sudo rmmod -f bluetooth

rmmod -f

4. rmmod -s

By default, error messages are sent to standard error. The -s option redirects error messages to the system log (syslog) instead of displaying them on the terminal.

Example:

rmmod -s bluetooth

rmmod -s

5. rmmod -V

This option will going to show version of program and then exit.

rmmod -V

rmmod -V

Conclusion

The rmmod command in Linux provides a direct way to unload kernel modules from the system. If you’re performing system maintenance, managing drivers, or troubleshooting, understanding how to use rmmod is essential. While the command is powerful, it should be used carefully, especially when forcing the removal of modules. In many cases, using modprobe -r may be safer due to its dependency handling.

rmmod command in Linux – FAQs

What is the rmmod command used for?

The rmmod command is used to remove or unload a module from the Linux kernel. It directly unloads a specified module, freeing up resources or disabling features associated with the module.

What is the difference between rmmod and modprobe -r?

While both commands can remove modules, modprobe -r handles module dependencies automatically, ensuring that dependent modules are also removed. rmmod, on the other hand, only tries to remove the specified module and will fail if there are dependencies.

What is the syntax for the rmmod command?

The basic syntax for removing a module is:

rmmod [options] [modulename]

How can I force the removal of a module using rmmod?

You can forcefully remove a module with the -f option, but this should be used with caution. For example:

sudo rmmod -f modulename

Next Article

Similar Reads

three90RightbarBannerImg
  翻译: