Linux

Rmmod Command in Linux

Rmmod Command in Linux

The core component of each Linux operating system is the Linux kernel. It manages the system's resources, and acts as an intermediary between the computer's hardware and software.

The Linux kernel is a software that has a modular design. A kernel module, or often referred to as a driver, is a piece of code that extends the kernel's functionality. Modules can be compiled as loadable modules or built into the kernel. Loadable modules can be dynamically loaded and unloaded in the running kernel on request, without the need to reboot the system.

In this article, we'll talk about how to use the rmmod command to remove modules from the Linux Kernel.

rmmod Command #

The general syntax for the rmmod (remove module) command is as follows:

rmmod [OPTIONS] MODULE_NAME… 

On modern Linux systems, rmmod is part of kmod, a binary that implements multiple programs used to manage Linux kernel modules.

Only users with administrative privileged can remove modules.

You can print a list of all modules loaded on your system with the lsmod command. The Kernel modules are stored in the /lib/modules/ directory.

Removing a module with the rmmod command is pretty simple; simply invoke the command followed by the module name:

rmmod module_name

The command prints message only if something goes wrong. For example, if another module uses the module, the command will print something like this:

rmmod: ERROR: Module module_name is in use by: module_name_2 

To display information about what the command is doing, use the -v (--verbose) option.

If you want to remove a module that is being used or not designed to be removed, invoke the command with the -f (--verbose) option. Using this option is extremely dangerous as it can cause a system crash.

rmmod also accepts multiple modules as arguments:

rmmod module_name1 module_name2

Prevent a Kernel Module from Loading at Boot-Time #

When a module is removed using the rmmod command, the module remains unloaded until the system is rebooted. On the next system boot, the removed module will be loaded.

To permanently disable a Kernel module from loading at boot-time, create a .conf file with any name inside the /etc/modprobe.d. The syntax is:

/etc/modprobe.d/blacklist.conf
blacklist module_name 

If you want to blacklist additional modules, specify the modules on a new line, or create a new .conf file.

Conclusion #

The rmmod command is used to remove Linux kernel modules. Generally, most Linux users are using the modprobe -r command instead of rmmod.

Feel free to leave a comment if you have any questions.

How to reverse Mouse and Touchpads scrolling direction in Windows 10
Mouse and Touchpads not only make computing easy but more efficient and less time-consuming. We cannot imagine a life without these devices, but still...
How to change Mouse pointer and cursor size, color & scheme on Windows 10
The mouse pointer and cursor in Windows 10 are very important aspects of the operating system. This can be said for other operating systems as well, s...
Gry Darmowe i otwarte silniki gier do tworzenia gier na Linuksa
Darmowe i otwarte silniki gier do tworzenia gier na Linuksa
Ten artykuł zawiera listę darmowych i otwartych silników gier, których można używać do tworzenia gier 2D i 3D w systemie Linux. Istnieje wiele takich ...