Skip to main content
Engineering LibreTexts

06-B.5.1: Kernel Module Management - insmod/rmmod Command

  • Page ID
    32782
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    The insmod Command

    The insmod command is used to insert modules into the kernel. Kernel modules are usually used to add support for new hardware (as device drivers) and/or filesystems, or for adding system calls. This command inserts the kernel object file (.ko) into the kernel.

    Syntax:

    insmod [file name] [module-options...]

    There are only 2 options - on -h for help, and -V fto show the version of insmod.

    This example shows running the insmod command from the /lib/modules/$(uname -r) directory, and that the .ko file exists in the specified directory.

    pbmac@pbmac-server $ insmod kernel/drivers/net/wireless/airo.ko
    pbmac@pbmac-server $ lsmod | grep axnet
    Module                  Size  Used by
    airo                   66291  0
    

    The rmmod Command

    The rmmod command is used to remove a module from the kernel. Most of the users use modprobe with the -r option instead of using rmmod.

    Syntax:

    rmmod [-f] [-s] [-v] [modulename]

    The rmmod command is extremely simple. You only need to give it the name of a module that you want to unload, and it will remove it. When you run the lsmod command looking for the module it should not find it. If you need the name, simply use lsmod to find the modules currently loaded, then remove the one you need.

    pbmac@pbmac-server $ rmmod axnet
    pbmac@pbmac-server $ lsmod | grep axnet
    pbmac@pbmac-server $
    

    Adapted from:
    "insmod command in Linux with examples" by Mukkesh Mckenzie, Geeks for Geeks is licensed under CC BY-SA 4.0
    "rmmod command in Linux with Examples" by rahulkumarmandal, Geeks for Geeks is licensed under CC BY-SA 4.0


    06-B.5.1: Kernel Module Management - insmod/rmmod Command is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?