Skip to content

modprobe command in Linux

The modprobe command in Linux is used to manage kernel modules. It allows users to insert, remove, and manipulate modules in the Linux kernel. Modprobe can also automatically load dependencies for a module being added. This command is essential for managing hardware drivers and configuring the kernel. By understanding the modprobe command, users can efficiently handle kernel modules to optimize system performance.

modprobe Syntax:

Terminal window
modprobe [options] module_name

Linux modprobe Options:

OptionDescription
-cUse the specified configuration file
-vShow verbose information
-nDry-run mode, show actions but do not execute them
-qQuiet mode, suppress normal output
-rRemove the specified module
-aInsert module even if already loaded
-sLog to the system log for each request
-tSet timeout value for network request completion
-DConsider dependencies during insertion and removal
-SCompute and resolve all module symbols

modprobe Parameters:

ParameterDescription
module_nameName of the module to insert or remove

How to use modprobe command:

Load a Module

Terminal window
modprobe <module_name>

Load the specified module into the Linux kernel.

Remove a Module

Terminal window
modprobe -r <module_name>

Unload the specified module from the Linux kernel.

Show Currently Loaded Modules

Terminal window
modprobe -l

Display a list of modules that are currently loaded in the Linux kernel.

Display Information about a Module

Terminal window
modprobe -c | grep <module_name>

Retrieve detailed information about a specific module.

Load a Module with Specific Parameters

Terminal window
modprobe <module_name> param1=value1 param2=value2

Load the module with specific parameters provided as key-value pairs.

List Dependencies of a Module

Terminal window
modprobe -c | grep -A <number_of_lines> depends <module_name>

Display the dependencies of a specific module by searching the module config file.

Prevent Module Autoloading

Terminal window
echo "blacklist <module_name>" | sudo tee /etc/modprobe.d/blacklist.conf

Create a blacklist configuration file to prevent a module from autoloading.

Disable Module Loading during Boot

Terminal window
echo "install <module_name> /bin/true" | sudo tee -a /etc/modprobe.d/blacklist.conf

Prevent a specific module from loading during boot by setting the install command to /bin/true in the blacklist configuration file.

How do I use modprobe in Linux?

To use the modprobe command in Linux, execute the following command:

Terminal window
modprobe --option <value>

What is the purpose of modprobe in Linux?

The modprobe command is used in Linux to add or remove kernel modules to the Linux kernel dynamically.

Terminal window
modprobe <module_name>

How can I list all currently loaded modules with modprobe?

To list all currently loaded modules using modprobe, run the following command:

Terminal window
lsmod

How do I remove a module using modprobe?

You can remove a module using modprobe in Linux with the following command:

Terminal window
modprobe -r <module_name>

Can I add multiple modules at once with modprobe?

Yes, you can add multiple modules at once using modprobe by listing them all in a single command:

Terminal window
modprobe <module1> <module2> <module3>

How can I get more information about a specific module using modprobe?

To get more information about a specific module using modprobe, you can use the modinfo command. For example:

Terminal window
modinfo <module_name>

How do I check if a module is currently loaded with modprobe?

You can check if a module is currently loaded with modprobe by using the following command:

Terminal window
lsmod | grep <module_name>

Yes, you can force loading a module with modprobe even if it might not be recommended by using the --force option. For example:

Terminal window
modprobe --force <module_name>

How do I see the dependencies of a module with modprobe?

To see the dependencies of a module using modprobe, you can use the following command:

Terminal window
modprobe --show-depends <module_name>

Applications of the modprobe command

  • Loading a specific kernel module
  • Unloading a kernel module
  • Listing currently loaded kernel modules
  • Adding or removing kernel module dependencies
  • Setting module options or parameters