insmod command in Linux systems is used to insert modules into the kernel. Linux is an Operating System which allows the user to load kernel modules on run time to extend the kernel functionalities. LKMs(Loadable Kernel Modules) are usually used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls. This command here inserts the kernel object file (.ko) into the kernel with/without arguments, along with a few additional options.
insmod [file name] [module-options...]
- insmod command with help option: The insmod command throws an error if no options, filename or arguments are passed. So, when we use the -h option, it gives the general syntax along with the various options that can be used with the insmod command.
- insmod command with version option: This is used to view the version of the insmod command.
- insmod + file name: This command is used to insert the LKM file (.ko) into the Linux Kernel. The working directory is changed to the one with the LKM file, and then the command is executed. Root privilege is needed to run this instruction.
Note: The LKM file used here is present in the desktop(which is the working directory), and doesn’t take any arguments, and prints a message to the system log. This message can be viewed by using the dmesg command.
sudo insmod geeksforgeeks.ko
- insmod + file directory + file name: Like the previous command, insmod works when you specify the file directory along with the LKM file’s name. This is illustrated below.
sudo insmod /home/mukkesh/Desktop/geeksforgeeks.ko
- Passing parameters to the module using insmod: LKM files can have parameters/arguments passed to them through the insmod command. These arguments essentially act as inputs for the LKMs. Depending on how the LKM is written, the arguments are used.
Note:The LKM used here takes the string parameter “user” and prints a message which includes the passed parameter.
sudo insmod geeks4geeks.ko user="Mukkesh"
- wc command in Linux with examples
- atq command in linux with examples
- man command in Linux with Examples
- look command in Linux with Examples
- fc Command in Linux with Examples
- df command in Linux with Examples
- ed command in Linux with examples
- du command in Linux with examples
- tar command in Linux with examples
- help Command in Linux with examples
- cpp command in Linux with Examples
- let command in Linux with Examples
- atd command in Linux with examples
- rcp Command in Linux with examples
- bc command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.