Understand the Purpose of rmmod Command
In this step, we will explore the purpose and usage of the rmmod
command in the Linux operating system. The rmmod
command is used to remove a kernel module from the running system.
Kernel modules are pieces of code that can be loaded and unloaded into the kernel as needed, without restarting the entire system. They provide a way to extend the functionality of the kernel, allowing you to add support for new hardware, file systems, network protocols, and more.
The rmmod
command is used to remove a kernel module from the system. This can be useful when you no longer need the functionality provided by a particular module, or when you need to replace a module with a newer version.
Let's start by listing the currently loaded kernel modules using the lsmod
command:
sudo lsmod
Example output:
Module Size Used by
vboxsf 106496 1
vboxguest 454656 0
snd_hda_codec_realtek 114688 1
snd_hda_codec_generic 86016 1 snd_hda_codec_realtek
snd_hda_intel 53248 0
snd_hda_codec 135168 3 snd_hda_codec_generic,snd_hda_codec_realtek,snd_hda_intel
snd_hda_core 90112 5 snd_hda_codec_generic,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec
snd_hwdep 16384 1 snd_hda_codec
snd_pcm 106496 4 snd_hda_intel,snd_hda_codec
snd_timer 32768 1 snd_pcm
snd 98304 21 snd_hda_codec_generic,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
soundcore 16384 1 snd
This output shows the currently loaded kernel modules. To remove a module, you can use the rmmod
command followed by the module name. For example, to remove the vboxsf
module, you would run:
sudo rmmod vboxsf
After running this command, you can verify that the module has been removed by running lsmod
again:
sudo lsmod
Example output:
Module Size Used by
vboxguest 454656 0
snd_hda_codec_realtek 114688 1
snd_hda_codec_generic 86016 1 snd_hda_codec_realtek
snd_hda_intel 53248 0
snd_hda_codec 135168 3 snd_hda_codec_generic,snd_hda_codec_realtek,snd_hda_intel
snd_hda_core 90112 5 snd_hda_codec_generic,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec
snd_hwdep 16384 1 snd_hda_codec
snd_pcm 106496 4 snd_hda_intel,snd_hda_codec
snd_timer 32768 1 snd_pcm
snd 98304 21 snd_hda_codec_generic,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer
soundcore 16384 1 snd
You can see that the vboxsf
module is no longer listed, indicating that it has been successfully removed.