modprobe Command Examples in Linux

The modprobe command is used to add or remove modules from a kernel. This command is capable of loading all the dependent modules before inserting the specified module. It is therefore preferred over using the insmod and rmmod commands.

To add modules using modprobe, use the -a option and specify the modules you want to add. To unload a module, use the -r option and specify the modules you want to remove.

The syntax of the modprobe command is:

# modprobe [options] [module names]

In addition to options for adding and removing modules, the modprobe command has more options.

Option Description
-f Force the module to be inserted or removed.
-n Conduct a dry run, i.e., output results without actually executing operations.
-s Print errors to the system log (syslog) rather than stderr.
-v Enable verbose mode.

modprobe Command Examples

1. Pretend to load a module into the kernel, but don’t actually do it:

# modprobe --dry-run module_name

2. Load a module into the kernel:

# modprobe module_name

3. Remove a module from the kernel:

# modprobe --remove module_name

4. Remove a module and those that depend on it from the kernel:

# modprobe --remove-dependencies module_name

5. Show a kernel module’s dependencies:

# modprobe --show-depends module_name
Related Post