The modprobe and depmod utilities are intended to make a Linux modular kernel more manageable for all users, administrators and distribution maintainers.
Modprobe uses a Makefile-like dependency file, created by depmod, to automatically load the relevant module(s) from the set of modules available in predefined directory trees.
Modprobe is used to load a single module, a stack of dependent modules, or all modules that are marked with a specified tag.
Modprobe will automatically load all base modules needed in a module stack, as described by the dependency file modules.dep. If the loading of one of these modules fails, the whole current stack of modules loaded in the current session will be unloaded automatically.
Modprobe has two ways of loading modules. One way (the probe mode) will try to load a module out of a list (defined by pattern). Modprobe stops loading as soon as one module loads successfully. This could be used to autoload one Ethernet driver out of a list. The other way modprobe can be used is to load all modules from a list.
With the option -r, modprobe will automatically unload a stack of modules, similar to the way rmmod -r does.
Note that using just modprobe -r will clean up unused autoloaded modules and also perform the pre-and post-remove commands in the configuration file /etc/modules, /etc/modprobe.d/*.
Combining the options -l and -t lists all available modules of a certain type.
Option -c will print the currently used configuration (default + configuration file). To do autoclean every 2 minutes:
'''/2 ''' * ''' ''' test -f /proc/modules && /sbin/modprobe -r