Bootstrap FreeKB - Linux Commands - modprobe (insert and remove modules)
Linux Commands - modprobe (insert and remove modules)

Updated:   |  Linux Commands articles

The following commands can be used to remove a kernel module

  • modprobe (this article)
  • rmmod

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
. . .

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


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