Skip to content

What is insmod Linux command?

The Linux insmod command is used to insert a module into the Linux kernel. It allows users to add new functionalities to the kernel on-demand without rebooting the system. The insmod command requires the path to the module to be specified, and it will insert the module along with its dependencies into the kernel.

insmod Syntax:

Terminal window
insmod [options] <module_name>

insmod Options:

OptionDescription
-fForce the module to load
-sLog to the system log when the module is loaded
-vDisplay verbose information
-m Specify the name of the module

Parameters:

ParameterDescription
module_nameThe name of the module to be loaded into the kernel

insmod Command Usage Examples:

Load a Kernel Module

Terminal window
insmod my_module.ko

This command loads the specified kernel module “my_module.ko” into the Linux kernel.

Load a Module with Parameters

Terminal window
insmod my_module.ko my_param=123

Loads the kernel module “my_module.ko” with the parameter “my_param” set to a value of 123.

Load a Module and Display Debug Messages

Terminal window
insmod -d my_module.ko

Loads the kernel module “my_module.ko” into the kernel and displays debug messages during the process.

Load a Module and Force Loading

Terminal window
insmod -f my_module.ko

Forces the loading of the kernel module “my_module.ko”, even if it may not be fully compatible.

Load a Module and Specify Module Path

Terminal window
insmod /path/to/my_module.ko

Loads the kernel module located at the specified path “/path/to/my_module.ko” into the Linux kernel.

How do I use insmod in Linux?

To use the insmod command in bash, execute the following command:

Terminal window
insmod <module_name>.ko

What is the syntax for insmod in Linux?

The syntax for the insmod command in Linux is as follows:

Terminal window
insmod [options] <module_name>.ko

How can I load a specific module with insmod?

To load a specific module using insmod, specify the full path to the module file, like this:

Terminal window
insmod /path/to/module/my_module.ko

How do I check the status of a module after using insmod?

To check the status of a module that was loaded using insmod, you can use the lsmod command like this:

Terminal window
lsmod | grep <module_name>

Can I unload a module loaded with insmod?

Yes, you can unload a module that was loaded with insmod using the rmmod command. For example:

Terminal window
rmmod <module_name>

How do I force insmod to load a module?

If you need to force insmod to load a module, you can use the -f flag like this:

Terminal window
insmod -f <module_name>.ko

How do I pass parameters to a module when using insmod?

To pass parameters to a module when loading it with insmod, use the modprobe command instead, like this:

Terminal window
modprobe <module_name> param1=value param2=value

Applications of the insmod command

  • Loading a specific kernel module into the kernel
  • Adding new functionality or features to the Linux kernel
  • Updating or replacing an existing kernel module
  • Debugging and testing new kernel modules
  • Overriding default kernel configurations
  • Providing support for new hardware devices