Master the modprobe Command in Linux [6 Examples Inside!]

Try this guide with our instant dedicated server for as low as 40 Euros

Imagine a toolbox filled with specialized tools, each designed to tackle a specific task for your Linux system. In a Linux environment, these tools are called kernel modules. Knowing how to manage them can unlock a whole new level of control and flexibility. 

This is where the mighty modprobe command comes in, allowing adding, removing, and keeping those modules in tip-top shape and handling dependencies automatically.

In this tutorial, we will discuss how to use the modprobe command in various use cases. 

Table Of Contents

  1. What is modprobe Command?
    1. Key Options for modprobe
  2. Alternative Commands
  3. Practical Examples of modprobe
    1. Example #1: Find Available Modules
    2. Example #2: Add a Module to the Kernel
    3. Example #3: Remove a Module From the Kernel
    4. Example #4: What to do if a Module Fails to Load?
    5. Example #5: Dealing with the Dependency Problems
    6. Example #6: Handle Conflicts with Existing Modules
  4. Conclusion
  5. FAQs

What is modprobe Command?

modprobe is a command-line-based utility in Linux-based operating systems that helps in removing and adding modules to the kernel. 

Kernel modules are components that can be loaded and unloaded into the kernel as needed, extending its functionality without requiring a reboot. These modules can include device drivers, filesystem drivers, and other types of system extensions.

The basic function of modprobe command is loading and unloading modules that are compiled code components that carry out a single specific function. 

The Basic Syntax

The modprobe command can load or unload a single module or multiple modules, as required by the situation. 

The basic syntax of modprobe command is as follows:

# sudo modprobe [options] [module name]

If you need to manage multiple modules at once, use the -a option and specify the multiple modules in the following format:

# sudo modprobe -a [module1] [module2]

Key Options for modprobe

Let us now discuss some of the options supported by the modprobe command. There are 3 types of options used with modprobe command:

Management Actions

The modprobe command provides several management options to control how kernel modules are loaded and unloaded. 

The following table summarizes common management options supported by modprobe command.

key options for modprobe

Information and Debugging

These options provide details about modules. You often see these options when troubleshooting issues. 

Options  Descriptions
-D, –show-depends Display the dependencies of a module without loading it.
-C, –config Specify an alternative configuration file instead of the default /etc/modprobe.conf or files in /etc/modprobe.d/
–dump-modversions, –show-modversions Dumps the module version dependencies.

Advanced Configuration

These options are used to fine-tune how kernel modules are loaded and managed on the system. It is used by experienced system administrators for specific purposes and is not necessarily required for everyday tasks. 

Options  Descriptions
-n, –dry-run Perform a trial run without making any changes, useful for testing.
-C, –config=<file name> Overrides the default configuration dependency. 
-d, –dirname=<directory> Uses the directory specified as the filesystem root for /lib/modules.
-S, –set-version=<version> Uses a specific kernel version specified instead of using the uname.
-s, –syslog Prints the error messages through Syslog instead of the standard error.
-q, –quiet  Suppress most messages, only showing errors.
-v, –verbose Provide detailed output for debugging purposes.
-V, –version Displays the modprobe version you currently have. 
-h, –help Displays help messages with all the options, information, and commands regarding modprobe.

Alternative Commands

While modprobe is commonly used, there are alternative commands for managing kernel modules:

  • insmod: Inserts a module into the kernel, but does not handle dependencies.
  • rmmod: Removes a module from the kernel.

Use these commands with caution and primarily stick to modprobe for automatic dependency handling.

Now that you have a basic understanding of modprobe, its syntax, and options, let us discuss some use cases. However, before that, let us take a quick look at the prerequisites. 

The Prerequisites

Before diving into the application scenarios, ensure you have the following:

  • A system running a popular Linux distribution.
  • A user account with sudo or administrative privileges

Practical Examples of modprobe

The modprobe command is a powerful command-line utility used in Linux systems to manage kernel modules. 

Let’s discuss the application scenarios where you can use this utility to manage kernel modules in Linux systems.

Example #1: Find Available Modules

All kernel modules are listed in the /lib/modules directory system in .ko (kernel object) files by default.

Execute the following command to find all the available modules for the current kernel version: 

# find /lib/modules/$(uname -r) -type f -name '*.ko*'| more

Find Available Modules

This command lists all kernel object files (.ko files) in the /lib/modules/$(uname -r) directory.

Example#2: Add a Module to the Kernel

Adding a module using modprobe enhances the Linux kernel’s functionality by dynamically extending its capabilities to support additional hardware, filesystems, network protocols, and features. 

This flexibility maintains a robust, efficient, and up-to-date system that can tackle changing workloads without requiring a system reboot.

Execute the following command to add a module to the kernel:

# sudo modprobe [module name]

For instance, run the following command to load the module called torture:

# sudo modprobe torture

Once you have added the module, it is necessary to check if the command executed successfully. 

We recommend the following command to check if the module is loaded appropriately:

# lsmod | grep torture

Example #3: Remove a Module From the Kernel

Removing a kernel module using the modprobe command is a crucial part of system administration and maintenance. The traditional way is to remove a module by adding the -r flag to the modprobe command:

# sudo modprobe -r [module name]

Replace [module name] with the actual module name.

To verify that the module is successfully unloaded, use –first-time option with -r. 

# sudo modprobe -r <module name> --first-time

An error message will be displayed indicating the module is not active in the kernel anymore.

Remove a Module From the Kernel

Alternatively, you can check the active module list and use grep to filter it for the desired module name. Continuing the previous example, the command would be as follows:

# lsmod | grep torture

If no output is displayed, the module has been successfully removed.

Example #4: What to do if a Module Fails to Load?

If a module fails to load, the underlying cause can be a typo in the name, or a version conflict. To get more details about the loading process and potential errors, use modprobe with the -v (verbose mode) flag:

# sudo modprobe -v [module name]

The information displayed can help you pinpoint the issue.

Example #5: Dealing with the Dependency Problems

Sometimes, a module relies on other modules to function properly (dependencies). If there’s a dependency issue preventing a module from loading, use the -D option with modprobe to list all the dependencies for a specific module:

# sudo modprobe -D [module name]

This will help you identify any missing dependencies that need to be loaded first.

Example #6: Handle Conflicts with Existing Modules

In rare cases, there might be conflicts between currently-loaded modules and the one you’re trying to load. 

In these instances, we recommend using –force option with caution, as it can potentially lead to system instability if there are genuine conflicts. The command syntax in this context will be:

# sudo modprobe --force [module name]

Note: We recommend to avoid –force unless you understand the potential risks and have exhausted other troubleshooting options.


Using modprobe effectively enhances your Linux system’s flexibility and performance by allowing you to manage kernel modules without restarting the system.

Familiarizing yourself with its options and usage helps in maintaining and troubleshooting the system efficiently.

For those looking to delve deeper, consider exploring more about compiling and customizing the Linux kernel itself.


Q. What is the modprobe command in Linux?

The modprobe command is a powerful command-line-based utility used for managing kernel modules. It can load, unload, and list modules as well as handle module dependencies automatically.

Q. How do I load a kernel module using modprobe?

You can load a module by executing sudo modprobe <module_name>. This command checks the module directory for the specified module file and loads it along with any dependent modules.

Q. Where are kernel modules located?

Kernel modules are typically located in the module directory, usually found at /lib/modules/$(uname -r)/. The exact path can vary based on the kernel version and distribution.

Q. What are module parameters and how do I set them?

Module parameters are options that can be passed to a module when it is loaded. You can set these parameters using the modprobe command like: sudo modprobe <module_name> param1=value1 param2=value2.

Q. What should I do if I encounter error messages while using modprobe?

Error messages can occur due to various reasons such as missing module files, version errors, or insufficient permissions. Check the standard error output for specific error messages and ensure you have sudo privileges.

Q. Can modprobe be used to unload modules?

Yes, you can unload modules using modprobe -r <module_name>. This will remove the specified module and any modules that depend on it if they are not in use.

Q. What is the difference between modprobe and insmod?

insmod simply inserts a module into the kernel without handling dependencies, while modprobe loads the module and automatically manages dependencies, making it more powerful and convenient for module management.

Q. How are modules loaded at boot time?

Modules can be loaded at boot time by adding their names to configuration files such as /etc/modules or by creating specific configuration files in /etc/modprobe.d/.

Q. How do I list all available kernel modules?

To list all available kernel modules, you can look through the directories under /lib/modules/$(uname -r)/kernel/ or use the find command- find /lib/modules/$(uname -r)/ -type f -name ‘*.ko*’.

Q. How does automatic loading of modules work?

Automatic loading of modules is handled by the kernel and modprobe. Configuration files and scripts can specify which modules to load automatically based on hardware detection or system events.

Q. What are common module management tasks?

Common tasks include loading modules with modprobe, unloading them with modprobe -r, listing active modules with lsmod, and configuring module parameters and options.

Q. How can I view the source code of a kernel module?

The source code for kernel modules is typically part of the Linux kernel source, which can be downloaded from the kernel.org website or obtained from your distribution’s package manager.

Try this guide with our instant dedicated server for as low as 40 Euros