modprobe Command in Linux: Load and Manage Kernel Modules

By 

Updated on

7 min read

Terminal showing Linux modprobe command examples for managing kernel modules

The Linux kernel is the core component of the Linux operating system. It manages the system’s resources and acts as a bridge between your computer’s hardware and software.

The Linux kernel has a modular design. A kernel module, often referred to as a driver, is a piece of code that extends the kernel’s functionality. Modules are either compiled as loadable modules or built into the kernel. Loadable modules can be loaded and unloaded in the running kernel on request, without the need to reboot the system.

Generally, modules are loaded on demand by udev (the device manager). However, sometimes you may need to fine-tune how modules are loaded. For example, you may need to load a module with additional parameters or prevent a module from loading automatically.

You can manually load a module into the kernel using the modprobe command, or automatically at boot time using /etc/modules-load.d/*.conf files. modprobe is part of kmod, a package that implements multiple utilities for managing Linux kernel modules.

This guide explains how to use modprobe to load, unload, blacklist, and configure kernel modules.

Syntax

The general syntax for the modprobe command is:

txt
modprobe [OPTIONS] module_name [parameter=value ...]

Common options:

  • -r — Remove (unload) a module from the kernel
  • -v — Verbose mode, show each step as modules are loaded or unloaded
  • -n — Dry run, do everything except actually load or unload the module
  • -c — Show the current modprobe configuration
  • --show-depends — List the dependencies of a module without loading it
  • --first-time — Fail if the module is already loaded (useful in scripts)

Loading Kernel Modules

Kernel modules are stored in the /lib/modules/<kernel_version> directory. You can find the version of the running kernel with the uname -r command.

Only users with administrative privileges can manage kernel modules.

To load a module, invoke modprobe followed by the module name:

Terminal
sudo modprobe module_name

modprobe loads the given module and any dependencies it requires. Only one module can be specified per command.

Use the lsmod command to confirm that the module is loaded:

Terminal
lsmod | grep module_name

To see exactly what modprobe does when loading a module, add the -v (verbose) flag:

Terminal
sudo modprobe -v module_name

If you want to test whether a module can be loaded without actually loading it, use the -n (dry run) option together with -v:

Terminal
sudo modprobe -n -v module_name

Loading Modules with Parameters

Some modules accept parameters that change their behavior. To load a module with parameters, pass them as parameter=value pairs after the module name:

Terminal
sudo modprobe module_name parameter=value

The command accepts multiple parameter=value pairs separated by spaces.

To see what parameters a module supports, use modinfo:

Terminal
modinfo -p module_name

Making Parameters Persistent

To set module parameters that apply every time the module is loaded, create a configuration file in /etc/modprobe.d/. Files must end with .conf and can have any name:

/etc/modprobe.d/module_name.confsh
options module_name parameter=value

For example, to always load the snd_hda_intel sound module with power_save=1:

/etc/modprobe.d/snd_hda_intel.confsh
options snd_hda_intel power_save=1

The settings in /etc/modprobe.d/ are read by modprobe every time the module is loaded, whether manually or at boot.

Loading Modules at Boot

To load a module automatically at boot time, add its name to a file in /etc/modules-load.d/. Each file lists one module name per line:

/etc/modules-load.d/modules.confsh
br_netfilter
vhost_net

These files are read by systemd-modules-load during startup. They only specify which modules to load; for parameters, use a separate file in /etc/modprobe.d/ as described above.

Removing Kernel Modules

To unload a module, invoke modprobe with the -r option followed by the module name:

Terminal
sudo modprobe -r module_name

modprobe will also remove any module dependencies that are no longer in use.

When invoked with -r, the command accepts multiple modules as arguments:

Terminal
sudo modprobe -r module_name1 module_name2
Tip
You can also use the rmmod command to unload a module from the Linux kernel. The difference is that rmmod only removes the specified module, while modprobe -r also removes unused dependencies.

Blacklisting Modules

If you want to prevent a kernel module from loading at boot time, you can blacklist it. Create a .conf file inside the /etc/modprobe.d/ directory:

/etc/modprobe.d/blacklist.confsh
blacklist module_name

If you want to blacklist multiple modules, add each one on a new line, or create separate .conf files.

To verify that the rule is in effect, run modprobe in dry-run mode with verbose output:

Terminal
sudo modprobe -n -v module_name

After blacklisting a module, rebuild the initramfs so the change takes effect on the next boot:

Terminal
sudo update-initramfs -u

On Fedora, RHEL, and Derivatives, use dracut instead:

Terminal
sudo dracut --force
Warning
Blacklisting only prevents automatic loading. A blacklisted module can still be loaded manually with sudo modprobe module_name or pulled in as a dependency of another module. To completely prevent loading, add install module_name /bin/false to the blacklist file.

Listing and Inspecting Modules

To list all currently loaded modules, use lsmod :

Terminal
lsmod

To view detailed information about a specific module (including its description, author, license, parameters, and file path), use modinfo:

Terminal
modinfo module_name

For example, to inspect the br_netfilter module:

Terminal
modinfo br_netfilter
output
filename:       /lib/modules/6.8.0-51-generic/kernel/net/bridge/br_netfilter.ko
description:    Linux ethernet netfilter bridge
author:         Lennert Buytenhek <buytenh@gnu.org>
license:        GPL
depends:        bridge
retpoline:      Y
intree:         Y
name:           br_netfilter
vermagic:       6.8.0-51-generic SMP preempt mod_unload modversions

To list only the parameters a module accepts:

Terminal
modinfo -p module_name

Practical Examples

Loading br_netfilter for Container Networking

Kubernetes and Docker require the br_netfilter module so that iptables rules apply to bridged traffic. To load it and make it persistent:

Terminal
sudo modprobe br_netfilter
/etc/modules-load.d/kubernetes.confsh
br_netfilter

Blacklisting the Nouveau Driver

When installing the proprietary NVIDIA driver, you need to blacklist the open-source nouveau driver to prevent conflicts:

/etc/modprobe.d/blacklist-nouveau.confsh
blacklist nouveau
options nouveau modeset=0

Then rebuild the initramfs and reboot:

Terminal
sudo update-initramfs -u
sudo reboot

Checking Module Dependencies Before Loading

To see what dependencies a module requires without loading anything:

Terminal
modprobe --show-depends vboxdrv

This is useful for debugging when a module fails to load due to missing dependencies.

Quick Reference

TaskCommand
Load a modulesudo modprobe module_name
Load with parameterssudo modprobe module_name param=value
Unload a modulesudo modprobe -r module_name
Dry run (test without loading)sudo modprobe -n -v module_name
Show module dependenciesmodprobe --show-depends module_name
Show modprobe configurationmodprobe -c
List loaded moduleslsmod
View module infomodinfo module_name
Blacklist a moduleecho 'blacklist module_name' >> /etc/modprobe.d/blacklist.conf
Load at bootAdd module name to /etc/modules-load.d/*.conf

Troubleshooting

“Module module_name not found”
The module does not exist for the running kernel version. Verify you are looking for the correct name with find /lib/modules/$(uname -r) -name '*.ko*' | grep keyword. On Ubuntu, you may need to install the linux-modules-extra-$(uname -r) package.

“modprobe: ERROR: could not insert module: Operation not permitted”
Loading modules requires root privileges. Run the command with sudo.

“modprobe: FATAL: Module module_name is in use”
The module cannot be unloaded because other modules or processes depend on it. Run lsmod | grep module_name to see what is using it. Unload the dependent modules first, or stop the processes that hold references to the module.

Module loads manually but does not persist across reboot
modprobe only loads a module for the current session. To make it persistent, add the module name to a file in /etc/modules-load.d/ as described in the Loading Modules at Boot section.

Module is blacklisted but still loads
A blacklist entry only prevents automatic loading by udev. If another module depends on the blacklisted module, it will still be loaded. Add install module_name /bin/false to the blacklist file to completely block it, then rebuild the initramfs.

FAQ

What is the difference between modprobe and insmod?
insmod loads a single module file by its full path and does not resolve dependencies. modprobe loads a module by name, automatically resolves and loads all dependencies, and reads configuration from /etc/modprobe.d/. In practice, modprobe is almost always the better choice.

How do I check if a kernel module is loaded?
Run lsmod | grep module_name. If the command produces output, the module is loaded. You can also check /proc/modules directly.

How do I permanently load a module at boot?
Add the module name (one per line) to a .conf file in /etc/modules-load.d/. For module parameters, create a separate file in /etc/modprobe.d/ with options module_name parameter=value.

How do I undo a blacklist?
Remove or comment out the blacklist module_name line from the file in /etc/modprobe.d/, then rebuild the initramfs with sudo update-initramfs -u (or sudo dracut --force on Fedora/RHEL) and reboot.

Conclusion

The modprobe command loads and unloads kernel modules along with their dependencies, while /etc/modprobe.d/ and /etc/modules-load.d/ handle persistent configuration and boot-time loading. For related commands, see lsmod for listing loaded modules and rmmod for removing individual modules.

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

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