How to Load and Unload Linux Kernel Modules

Linux kernel modules are handy little pieces of the kernel that you can add or remove on-demand, without having to compile them directly into the kernel.  This allows third-party developers to create programs that require kernel-level access but that are not part of the Linux kernel and may not even be open source.  For dedicated servers, this is important because you can add virtualization tools or even new hardware with little or no down time.

You can manipulate Linux kernel modules with a few simple commands.  For some modules (i.e. for your network card), it is a good idea to be sitting right in front of the console or using KVM.  For others, it is enough to perform the tasks from within SSH.

depmod – This command shows the dependencies of a module
insmod – Installation of a module (useful if you compiled a module and need to install it)
lsmod – This command lists all currently loaded modules.  You may also find it helpful to use grep to sort for only the ones you want to view.
modinfo – Use this command to display useful information about a module
rmmod – With rmmod, you can remove a currently installed module.  You should note that any modules currently in use or with other modules that depend upon it will not be removed.

The main module configuration file on most systems is modules.conf.  With it you can load modules at boot automatically.  For more information about any of these commands, type “man” followed by the command name from the shell prompt.