Software & Apps Linux Linux/Unix Command: modprobe Load kernel modules on your Linux system By Juergen Haas Writer Former Lifewire writer Juergen Haas is a software developer, data scientist, and a fan of the Linux operating system. our editorial process Juergen Haas Updated March 13, 2020 Linux Switching from Windows Tweet Share Email The Linux kernel has grown into a large piece of software. In some ways, that's a good thing. In others, it makes it somewhat inflexible. The solution is to break parts of the kernel into modules. These modules can be loaded or not, given the computer's configuration and your needs. The modprobe command loads new kernel modules on a Linux system, allowing you to enable new features and support without a reboot. Westend61 / Getty Images Using Modprobe Modprobe is usually simple to use. Once you know the kernel module that you want to load, pass it to the modprobe command. sudo modprobe rtl8723de That's all there is to it. The module is loaded until you reboot your system. If you want to remove a module without rebooting, rerun the command with the -r flag. sudo modprobe -r rtl8723de For the most part, this is how you'll work with modprobe. To find out more, check into the technical documentation below. Modprobe Technical Documentation The modprobe command performs high-level handling of loadable modules. Synopsis modprobe [-adnqv] [-C config] module [symbol=value ...] modprobe [-adnqv] [-C config] [-t type] pattern modprobe -l [-C config] [-t type] pattern modprobe -c [-C config] modprobe -r [-dnv] [-C config] [module ...] modprobe -Vh Options -a, --all Load all matching modules instead of stopping after the first successful loading. -c, --showconfig Show the currently used configuration. -C, --config config Use the file config instead of (the optional) /etc/modules.conf to specify the configuration. The environment variable MODULECONF can also be used to select (and override) a different configuration file from the default /etc/modules.conf (or /etc/conf.modules which is deprecated). When environment variable UNAME_MACHINE is set, modutils uses its value instead of the machine field from the uname() syscall. This is mainly of use when compiling 64-bit modules in a 32-bit user space or vice versa, set UNAME_MACHINE to the type of the modules. Current modutils doesn't support full cross-build mode for modules, it is limited to choosing between 32-bit and 64-bit versions of the host architecture. -d, --debug Show information about the internal representation of the stack of modules. -h, --help Display a summary of options and immediately exit. -k, --autoclean Set autoclean on loaded modules. Used by the kernel when it calls on modprobe to satisfy a missing feature (supplied as a module). The -q option is implied by -k. These options are automatically sent to insmod. -n, --show Don't perform the action, only show what would be done. -q, --quiet Don't complain about insmod failing to install a module. Continue as normal, but silently, with other possibilities for modprobe to test. This option is automatically sent to insmod. -r, --remove Remove module (stacks) or do autoclean, depending on whether there are any modules mentioned on the command line. -s, --syslog Report via syslog instead of stderr. This option is automatically sent to insmod. -t moduletype; --type moduletype Only consider modules of this type. modprobe only looks at modules whose directory path includes exactly /moduletype/. moduletype can include more than one directory name, for example, -t drivers/net lists modules in xxx/drivers/net/ and its subdirectories. -v, --verbose Print all commands as they are executed. -V, --version Display the version of modprobe. Module names must not contain paths (no /), nor may the name contain the trailing .o. For example, slip is a valid module name for modprobe, /lib/modules/2.2.19/net/slip and slip.o are invalid. This applies to the command line and to entries in the config. Description of the Command The modprobe and depmod utilities are intended to make a Linux modular kernel more manageable for users, administrators, and distribution maintainers. Modprobe uses a Makefile-like dependency file, created by depmod, to automatically load the relevant modules 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 automatically loads 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 are 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 automatically unloads a stack of modules, similar to the way rmmod -r does. Using only modprobe -r cleans up unused autoloaded modules and also performs the pre- and post-remove commands in the configuration file /etc/modules.conf. Combining the options -l and -t lists all available modules of a certain type. Option -c prints the currently used configuration (default + configuration file). Configuration The behavior of modprobe (and depmod) can be modified by the (optional) configuration file /etc/modules.conf. For a detailed description of what this file can contain, as well as the default configuration used by depmod and modprobe, see modules.conf(5). The pre- and post-remove commands aren't executed if a module is autocleaned by kerneld. Look for the up-coming support for persistent module storage instead. If you want to use the pre- and post-install features, turn off autoclean for kerneld and instead put something like the following line in crontab (this is used for kmod systems, as well) to do autoclean every 2 minutes: */2 * * * * test -f /proc/modules && /sbin/modprobe -r Strategy The idea is that modprobe will look first in the directory containing modules compiled for the current release of the kernel. If the module isn't found there, modprobe looks in the directory common to the kernel version (for example, 2.0, 2.2). If the module still isn't found, modprobe looks in the directory containing modules for a default release, and so on. When you install a new Linux, the modules should be moved to a directory related to the release (and version) of the kernel you are installing. Then, do a symlink from this directory to the default directory. Each time you compile a new kernel, the command make modules_install creates a new directory, but won't change the default link. When you get a module unrelated to the kernel distribution, place it in one of the version-independent directories under /lib/modules. This is the default strategy, which can be overridden in /etc/modules.conf. Examples modprobe -t net Load one of the modules that are stored in the directory tagged net. Each module is tried until one succeeds. modprobe -a -t boot All modules that are stored in directories tagged boot are loaded. modprobe slip This attempts to load the module slhc.o if it was not previously loaded since the slip module needs the functionality in the slhc module. This dependency is described in the file modules.dep that was created automatically by depmod. modprobe -r slip This unloads the slip module. It also unloads the slhc module automatically, unless it is used by some other module as well (for example, ppp). See also: depmod(8), lsmod(8), kerneld(8), ksyms(8), rmmod(8). Safe Mode If the effective uid is not equal to the real uid, then modprobe treats its input with extreme suspicion. The last parameter is always treated as a module name, even if it starts with -. There can only be one module name and options of the form variable=value are forbidden. The module name is always treated as a string, no meta expansion is performed in safe mode. However, meta expansion is applied to data read from the config file. euid may not be equal to uid when modprobe is invoked from the kernel, this is true for kernels 2.4.0-test11 and later. In an ideal world, modprobe could trust the kernel to only pass valid parameters to modprobe. However, at least one local root exploit has occurred because high-level kernel code passed unverified parameters direct from the user to modprobe. So modprobe no longer trusts kernel input. modprobe automatically sets safe mode when the environment consists only of these strings HOME=/ TERM=linux PATH=/sbin:/usr/sbin:/bin:/usr/bin This detects modprobe execution from the kernel on kernels 2.2 though 2.4.0-test11, even if uid == euid, which it does on the earlier kernels. Logging Commands If the directory /var/log/ksymoops exists and modprobe is run with an option that could load or a delete a module, modprobe logs its command and return the status in /var/log/ksymoops/'date +%Y%m%d.log'. There is no switch to disable this automatic logging, if you don't want it to occur, do not create /var/log/ksymoops. If that directory exists, it should be owned by root and be mode 644 or 600 and you should run script insmod_ksymoops_clean every day or so. Required Utilities depmod(8), insmod(8). Use the man command (% man) to see how a command is used on your computer.