Website Vidya
Linux & ServersStep-by-Step Guide

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.

RR
Rajesh RayLead Systems Educator
Published:
11 min read
PDF Cheat Sheet
modprobe Command in Linux: Load, Unload & Configure Kernel Modules
AI Executive SummaryWebsiteVidya AI

11 min read

Learn modprobe command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

Key Highlights
  • What modprobe Does and When to Use It
  • Availability and Installation Across Linux Distributions
  • Command Syntax, Arguments, and Exit Status Codes
Grounded in full engineering runbookWebsiteVidya AI Engine

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.

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.

Advertisement
modprobe Command in Linux: Load, Unload & Configure Kernel Modules — syntax, flags, and practical terminal workflow diagram
modprobe Command in Linux: Load, Unload & Configure Kernel Modules — command syntax, key options, and production workflow reference.

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:

Advertisement

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 / FlagLong Form / ArgumentTechnical Behavior and Purpose
-v--verbosePrints every low-level action taken by modprobe, including each insmod or rmmod operation executed along the dependency chain.
-n--dry-run / --showSimulates the load or unload operation without actually calling kernel syscalls; combine with -v (-nv) to preview actions.
-r--removeUnloads the specified module and recursively removes any unused prerequisite modules it depended on.
-a--allInserts or removes multiple module names specified on the command line in a single invocation.
-b--use-blacklistApplies blacklist directives from /etc/modprobe.d/*.conf to explicit module names passed on the command line.
-c--showconfigDumps the complete effective configuration merged from /lib/modprobe.d, /run/modprobe.d, and /etc/modprobe.d.
--show-depends--show-dependsLists the exact file paths of all prerequisite modules required by the target module in load order (implies dry-run).
-f--forceAttempts to strip vermagic and modversions metadata to force-load a module compiled for a slightly different kernel version (hazardous).
-S--set-version=VERSIONInspects 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.

Advertisement

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

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

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
The insmod utility is a low-level tool that takes an explicit file path (such as /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.
Run lsmod (which formats the contents of /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.
If the module can be unloaded safely, run sudo modprobe -r module_name followed by sudo modprobe module_name param=value. If the module is built-in or cannot be unloaded, check /sys/module/<module_name>/parameters/: parameters with writable permission bits (such as 0644) can be updated live by writing to the sysfs file (e.g., echo 1 | sudo tee /sys/module/kvm/parameters/ignore_msrs).
A blacklist directive only blocks the module's internal hardware aliases from triggering automatic udev loading; if another non-blacklisted module depends on it, or if a script invokes modprobe without -b, it will still load. To block loading completely, add install module_name /bin/false below the blacklist line in your /etc/modprobe.d/*.conf file and rebuild initramfs (sudo update-initramfs -u or sudo dracut -f).
RR
Written byVerified Author

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.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout