Insert and remove modules using the MODPROBE command in Linux

Home > Search > Linux commands
  by

The modprobe command can be used to insert and remove modules in the kernel. The file for a certain module will be somewhere below the /lib/modules directory. The lsmod command can be used to list the modules that are currently loaded into the kernel. In this example, the bcma module is not currently loaded into the kernel.

[john.doe@server1 ~]# lsmod | sort
arc4         12608  0
ata_generic  12910  0
ata_piix     35038  0
auth_rpcgss  59314  1  nfsd
bluetooth   372944  5  bnep
. . .

 

The modinfo command shows that the filename for the bcma module is /lib/modules/3.10.0-327.36.3.el7.x86_64/kernel/drivers/bcma/bcma.ko.

[john.doe@server1 ~]# modinfo -n bcma
filename:    /lib/modules/3.10.0-327.36.3.el7.x86_64/kernel/drivers/bcma/bcma.ko

 

The modprobe command followed by the name of a module can be used to load the module into the kernel. In this example, the bcma module is loaded into the kernel.

[john.doe@server1 ~]# modprobe /lib/modules/3.10.0-327.36.3.el7.x86_64/kernel/drivers/bcma/bcma.ko

 

The lsmod command now shows that the bcma module is loaded into the kernel.

[john.doe@server1 ~]# lsmod | sort
arc4         12608  0
ata_generic  12910  0
ata_piix     35038  0
auth_rpcgss  59314  1  nfsd
bcma         51886  0
bluetooth   372944  5  bnep
. . .

 


Remove a module

The -r or --remove option can be used to remove a module from the kernel. In this example, the bcma module is removed.

[john.doe@server1 ~]# modprobe -r /lib/modules/3.10.0-327.36.3.el7.x86_64/kernel/drivers/bcma/bcma.ko

 

The lsmod command now shows that the bcma module is no longer loaded into the kernel.

[john.doe@server1 ~]# lsmod | sort
arc4         12608  0
ata_generic  12910  0
ata_piix     35038  0
auth_rpcgss  59314  1  nfsd
bluetooth   372944  5  bnep
. . .

 

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments