modprobe Command in Linux: Load, Unload & Configure Kernel Modules
Learn modprobe command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.
11 min read
Learn modprobe command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.
- What modprobe Does and When to Use It
- Availability and Installation Across Linux Distributions
- Command Syntax, Arguments, and Exit Status Codes
The Linux kernel uses a modular architecture that keeps the core kernel image compact while allowing hardware device drivers, filesystems (ext4, XFS, ZFS, NFS), network protocols (WireGuard, bridge, bonding), and Netfilter firewall extensions to be loaded dynamically on demand. Using the modprobe command in linux is the standard administrative method for inserting, configuring, and removing these Loadable Kernel Modules (.ko, .ko.xz, or .ko.zst files) at runtime without rebooting the server.
The modprobe command in Linux intelligently loads and removes Loadable Kernel Modules (LKMs) from the running Linux kernel while automatically resolving module dependencies, soft dependencies, aliases, and blacklists. Run sudo modprobe module_name to load a driver and its prerequisites, or sudo modprobe -r module_name to unload an unused module tree safely.
While low-level utilities like insmod and rmmod require you to provide exact file paths and manually load every prerequisite module in topological order, modprobe reads dependency graphs generated by depmod inside /lib/modules/$(uname -r)/modules.dep.bin. It automatically loads required dependency chains, applies administrator parameters defined in /etc/modprobe.d/, and respects module blacklists.
This guide explains how modprobe interacts with the finit_module(2) and delete_module(2) kernel system calls, compares its flags and dry-run modes, walks through practical driver and networking module examples, and covers Secure Boot module signature verification.
What modprobe Does and When to Use It
Provided by the kmod package (where modprobe, lsmod, insmod, rmmod, modinfo, and depmod are all symbolic links to the unified /bin/kmod binary), modprobe begins by querying the running kernel release via uname(2) and opening the binary index files inside /lib/modules/$(uname -r)/—specifically modules.dep.bin, modules.alias.bin, and modules.softdep. It then parses configuration files across /lib/modprobe.d/, /run/modprobe.d/, and /etc/modprobe.d/*.conf to apply alias mappings, default module options, and blacklist directives.
Once the dependency DAG (Directed Acyclic Graph) is resolved, modprobe opens each required .ko (or compressed .ko.zst / .ko.xz) object file, decompresses it in memory if needed, and invokes the finit_module(2) or init_module(2) system call. Inside the kernel, the module loader verifies the ELF header, checks cryptographic signatures against the kernel keyring when Lockdown or Secure Boot is active, resolves exported kernel symbols, and executes the module's initialization function. Loaded modules immediately register under /sys/module/<name>/ and appear in /proc/modules.
Under the hood, modprobe gathers runtime telemetry or dispatches control signals by reading virtual filesystems mounted at /proc and /sys, or by communicating with PID 1 (systemd) over D-Bus. Using flags such as -v, -n, -r, -a turns raw process and service tables into actionable diagnostics during incident response.
Availability and Installation Across Linux Distributions
The modprobe utility is packaged in kmod across mainstream Linux distributions. It is pre-installed on standard Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Fedora, and Arch Linux systems, while minimal container images may require manual installation:
Before running administrative tasks or automation scripts, verify whether modprobe is installed and inspect which binary path and version your shell resolves:
type -a modprobe
modprobe --version 2>/dev/null || man -f modprobe
# Illustrative output (reviewed against documentation)
modprobe is /usr/bin/modprobe
modprobe (kmod)
# Debian / Ubuntu
sudo apt-get update && sudo apt-get install -y kmod
# RHEL / Rocky / AlmaLinux / Fedora
sudo dnf install -y kmod
# Arch Linux
sudo pacman -S --noconfirm kmod
# Alpine Linux
sudo apk add --no-cache kmod
Command Syntax, Arguments, and Exit Status Codes
modprobe [OPTIONS] MODULE_NAME [SYMBOL=VALUE...]
The command syntax is modprobe [OPTIONS] MODULE_NAME [PARAMETER=VALUE...]. Note that modprobe normalizes hyphens (-) and underscores (_) interchangeably in module names: running modprobe br-netfilter and modprobe br_netfilter resolve to the exact same kernel module. When loading a module, you can append space-separated KEY=VALUE parameters (for example, sudo modprobe bonding mode=4 miimon=100) to configure driver behavior at insertion time.
When unloading a module with -r (--remove), you do not pass module parameters. Instead, modprobe -r MODULE_NAME invokes the delete_module(2) syscall on the target module (provided its kernel reference count in lsmod is 0) and recursively unloads any prerequisite modules that are no longer used by any other loaded module.
0— Module (and all dependencies) loaded, removed, or simulated successfully.1— Operational failure: module not found in/lib/modules/$(uname -r), permission denied (EPERM), module is in use during-r, or signature verification failed (EKEYREJECTED).2— Invalid command-line option or syntax error.
Important Options and Flags Reference
| Option / Flag | Long Form / Argument | Technical Behavior and Purpose |
|---|---|---|
-v | --verbose | Prints every low-level action taken by modprobe, including each insmod or rmmod operation executed along the dependency chain. |
-n | --dry-run / --show | Simulates the load or unload operation without actually calling kernel syscalls; combine with -v (-nv) to preview actions. |
-r | --remove | Unloads the specified module and recursively removes any unused prerequisite modules it depended on. |
-a | --all | Inserts or removes multiple module names specified on the command line in a single invocation. |
-b | --use-blacklist | Applies blacklist directives from /etc/modprobe.d/*.conf to explicit module names passed on the command line. |
-c | --showconfig | Dumps the complete effective configuration merged from /lib/modprobe.d, /run/modprobe.d, and /etc/modprobe.d. |
--show-depends | --show-depends | Lists the exact file paths of all prerequisite modules required by the target module in load order (implies dry-run). |
-f | --force | Attempts to strip vermagic and modversions metadata to force-load a module compiled for a slightly different kernel version (hazardous). |
-S | --set-version=VERSION | Inspects module dependencies for an alternate installed kernel version under /lib/modules/VERSION instead of uname -r. |
Before loading or unloading kernel modules on a production server, combining -n and -v (modprobe -nv MODULE or --show-depends) lets you inspect the exact sequence of insmod and install commands that modprobe plans to execute without touching the running kernel.
Pay special attention to how module blacklisting works: placing blacklist nouveau in /etc/modprobe.d/blacklist.conf prevents the kernel's udev hardware auto-detection aliases from loading nouveau automatically, but a root user running sudo modprobe nouveau will STILL load it unless the -b (--use-blacklist) flag is passed. To block a module from being loaded even directly, administrators combine blacklist with install module_name /bin/false.
When combining short flags on the command line, POSIX and GNU utilities allow clustering boolean flags behind a single hyphen, provided any option taking an argument appears last. In automated shell scripts, using long-form GNU options where portable makes self-documenting code that is easier to audit during peer review.
Practical Basic and Advanced Usage Examples
1. Preview Module Dependencies Before Loading (--show-depends)
Use --show-depends to inspect the full dependency chain and compressed file paths for the overlay and br_netfilter modules required by Kubernetes and Docker.
modprobe --show-depends br_netfilter
modprobe --show-depends overlay
# Illustrative output (reviewed against documentation)
insmod /lib/modules/6.8.0-45-generic/kernel/net/802/stp.ko.zst
insmod /lib/modules/6.8.0-45-generic/kernel/net/llc/llc.ko.zst
insmod /lib/modules/6.8.0-45-generic/kernel/net/bridge/bridge.ko.zst
insmod /lib/modules/6.8.0-45-generic/kernel/net/bridge/br_netfilter.ko.zst
insmod /lib/modules/6.8.0-45-generic/kernel/fs/overlayfs/overlay.ko.zst
As shown in the output, loading br_netfilter requires loading stp, llc, and bridge first. Running modprobe br_netfilter handles this entire 4-module sequence automatically.
2. Load Kernel Modules Verbosely and Verify with lsmod
Load both the overlay and br_netfilter modules using -a (all) and -v (verbose), then verify their active presence and reference counts in lsmod.
sudo modprobe -av overlay br_netfilter
lsmod | grep -E '^(Module|overlay|br_netfilter|bridge)'
# Illustrative output (reviewed against documentation)
insmod /lib/modules/6.8.0-45-generic/kernel/fs/overlayfs/overlay.ko.zst
insmod /lib/modules/6.8.0-45-generic/kernel/net/bridge/br_netfilter.ko.zst
Module Size Used by
br_netfilter 32768 0
bridge 417792 1 br_netfilter
overlay 212992 0
In the lsmod output, the 'Used by' column confirms that bridge now has a reference count of 1 because br_netfilter depends on it.
3. Load a Module with Runtime Configuration Parameters
Inspect valid module parameters using modinfo -p and load the dummy virtual network driver with numdummies=2 to create two virtual test interfaces.
modinfo -p dummy
sudo modprobe -v dummy numdummies=2
ip -br link show type dummy
# Illustrative output (reviewed against documentation)
numdummies:Number of dummy pseudo devices (int)
insmod /lib/modules/6.8.0-45-generic/kernel/drivers/net/dummy.ko.zst numdummies=2
dummy0 DOWN ca:4f:19:82:11:01 <BROADCAST,NOARP>
dummy1 DOWN 7e:91:04:55:2a:02 <BROADCAST,NOARP>
Always check modinfo -p <module> before passing parameters so you don't pass a misspelled option that causes the module load to fail with Unknown parameter.
4. Safely Unload a Kernel Module and Unused Dependencies (-r)
Use sudo modprobe -rv to unload the dummy and br_netfilter modules and automatically clean up prerequisite modules whose reference counts reach zero.
sudo modprobe -rv dummy br_netfilter
# Illustrative output (reviewed against documentation)
rmmod dummy
rmmod br_netfilter
rmmod bridge
rmmod stp
rmmod llc
Because bridge, stp, and llc had no other active users once br_netfilter was removed, modprobe -rv cleanly unloaded the entire dependency stack.
5. Simulate Module Removal or Insertion with Dry-Run (-nv)
Test what modprobe would do when loading a module with custom options by passing -nv (--dry-run --verbose) without requiring root privileges.
modprobe -nv bonding mode=4 miimon=100
# Illustrative output (reviewed against documentation)
insmod /lib/modules/6.8.0-45-generic/kernel/drivers/net/bonding/bonding.ko.zst mode=4 miimon=100
Dry-run mode (-nv) validates that the module exists for the current kernel and previews merged options from /etc/modprobe.d/ alongside command-line arguments.
6. Audit Effective Module Options and Blacklists (-c)
Query the merged modprobe configuration table with -c and grep for blacklisted modules or persistent driver parameter overrides.
modprobe -c | grep -E '^(blacklist|options) ' | head -n 6
# Illustrative output (reviewed against documentation)
blacklist evbug
blacklist floppy
blacklist pcspkr
options bonding max_bonds=0
options kvm_intel nested=1
options zfs zfs_arc_max=8589934592
Running modprobe -c is the fastest way to verify whether a configuration snippet in /etc/modprobe.d/ is being parsed properly.
Real-World Workflows, Pipelines, and Shell Automation
Persistent Kubernetes Node Kernel Module Provisioning (/etc/modules-load.d)
Modules loaded manually via modprobe are lost on reboot. On systemd Linux distributions, configure persistent boot-time module loading in /etc/modules-load.d/ and persistent module options in /etc/modprobe.d/, then apply immediately.
cat << 'EOF' | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF
sudo modprobe -av overlay br_netfilter
sudo systemctl restart systemd-modules-load.service
systemctl status --no-pager systemd-modules-load.service | head -n 5
# Illustrative output (reviewed against documentation)
overlay
br_netfilter
● systemd-modules-load.service - Load Kernel Modules
Loaded: loaded (/usr/lib/systemd/system/systemd-modules-load.service; static)
Active: active (exited) since Thu 2026-10-22 18:30:12 UTC; 2s ago
Testing with sudo systemctl restart systemd-modules-load.service immediately verifies that your /etc/modules-load.d/*.conf syntax is valid and will succeed on the next reboot.
Hardening a Server by Permanently Disabling Unused Filesystem or Network Modules
To satisfy CIS Benchmark security controls (such as disabling uncommon filesystems like cramfs or network protocols like sctp/rds), create a hardening file in /etc/modprobe.d/ combining blacklist and install /bin/false.
cat << 'EOF' | sudo tee /etc/modprobe.d/cis-hardening.conf
blacklist cramfs
install cramfs /bin/false
blacklist rds
install rds /bin/false
EOF
modprobe -nv cramfs
# Illustrative output (reviewed against documentation)
install /bin/false
As shown by modprobe -nv cramfs, the install cramfs /bin/false directive intercepts any attempt to load cramfs and executes /bin/false instead of inserting the kernel object.
Pipelines, Redirection, Quoting, and Shell Expansion
When embedding modprobe inside shell pipelines (|), conditional chains (&& and ||), or command substitutions ($(...)), the calling shell performs tilde expansion, variable interpolation, and globbing before invoking the binary. Always wrap paths, patterns, and variables in quotes so whitespace and wildcard characters (*, ?) are not expanded prematurely, and use set -euo pipefail in unattended scripts.
Permissions, Security Implications, and Safe Execution
Never run modprobe -r on storage controller drivers (nvme, ahci, virtio_blk, megaraid_sas), root filesystem drivers (ext4, xfs), or active primary NIC drivers (virtio_net, ena, ixgbe, mlx5_core) on a remote server. Unloading an active network driver immediately drops all network interfaces backed by that driver.
Loading or unloading kernel modules requires the CAP_SYS_MODULE capability because kernel modules execute in Ring 0 (kernel space) with unrestricted access to physical memory and hardware registers. If an attacker gains root access with CAP_SYS_MODULE intact, they can load a kernel-mode rootkit LKM unless mitigations are enforced.
High-security production servers protect against unauthorized module loading using two kernel mechanisms: UEFI Secure Boot with CONFIG_MODULE_SIG_FORCE (or kernel lockdown mode integrity/confidentiality), which rejects any .ko file not signed by a trusted X.509 key in the kernel keyring; and the /proc/sys/kernel/modules_disabled sysctl knob (which, once set to 1, irreversibly disables all further module loading until the next physical reboot).
GNU/Linux, BSD, and BusyBox Implementation Differences
The modprobe utility and /lib/modules/$(uname -r) hierarchy are specific to the Linux kernel. Inside Docker or Kubernetes containers, the container shares the host's running Linux kernel; containers Drop CAP_SYS_MODULE by default and usually do not mount the host's /lib/modules directory, so kernel modules required by workloads must be loaded on the host node before starting pods.
On FreeBSD, kernel modules are managed using kldload, kldunload, and kldstat (reading from /boot/kernel/*.ko). On macOS, kernel extensions have largely been replaced by userspace DriverKit system extensions managed via systemextensionsctl and kmutil.
Troubleshooting Common Errors and Diagnostics
modprobe: FATAL: Module wireguard not found in directory /lib/modules/6.8.0-44-generic
Root Cause: Often occurs immediately after a system package upgrade (apt upgrade / dnf update) installed a newer kernel (e.g., 6.8.0-45) and cleaned up or moved modules before the server was rebooted, OR the extra modules package (linux-modules-extra-$(uname -r)) is missing.
Resolution: Compare uname -r with ls /lib/modules/. If a newer kernel was installed, reboot into the new kernel; otherwise install linux-modules-extra-$(uname -r) and run sudo depmod -a.
uname -r
ls -1 /lib/modules/
sudo depmod -a
modprobe: FATAL: Module nvidia is in use
Root Cause: You ran modprobe -r on a module whose kernel reference count in lsmod is greater than 0 because a userspace process, open device node, or dependent kernel module is actively using it.
Resolution: Check the 'Used by' column in lsmod | grep <module> and inspect open device nodes with sudo lsof /dev/<device>* to stop the dependent processes first.
lsmod | grep -E '^(Module|nvidia)'
modprobe: ERROR: could not insert 'vboxdrv': Key was rejected by service
Root Cause: UEFI Secure Boot and Kernel Lockdown are enabled on the system, and the third-party or DKMS-compiled kernel module (.ko) is not cryptographically signed with an enrolled Machine Owner Key (MOK).
Resolution: Sign the module using kmodsign / sign-file with your enrolled MOK key (mokutil --import), or disable Secure Boot if organizational policy permits.
mokutil --sb-state
Alternatives, Related Commands, and Related Tutorials
- Diagnose OOM Killer Events in Linux: Logs & Memory Tuning — Practical syntax, flags, and examples for
dmesg. - How to Check Linux Version: Distro & Kernel Commands — Practical syntax, flags, and examples for
uname. - fdisk Command in Linux: Create & Manage Disk Partitions — Practical syntax, flags, and examples for
fdisk. - Mount & Unmount File Systems in Linux: mount & umount — Practical syntax, flags, and examples for
mount. - 25 Best Linux Commands Every Sysadmin Should Know — Core command-line utilities for daily Linux server administration.
- How to Find a File in Linux from the Command Line — Practical file search patterns across Linux directories.
- Linux Commands Knowledge Hub (#linux-commands) — Browse all Linux command-line tutorials and system administration references.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
/lib/modules/.../foo.ko) and attempts to load that single file into the kernel without resolving dependencies or reading /etc/modprobe.d/. The modprobe utility is a high-level manager that takes a module name, looks up all prerequisite modules in modules.dep, loads the entire dependency chain in order, and applies /etc/modprobe.d/ options and blacklists./proc/modules into a readable table showing module name, memory size in bytes, reference count, and dependent modules). To inspect detailed metadata, version, file path, and parameters for a specific module, run modinfo module_name./sys/module/kvm/parameters/ignore_msrs)./bin/false below the blacklist line in your /etc/modprobe.d/*.conf file and rebuild initramfs (sudo update-initramfs -u or sudo dracut -f).Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!