Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Linux Kernel Modules

List of modules

lsmod 

Getting info

modinfo <modules>

Inserting a module

insmod <module> [params]
modprobe -a <module> [params]

insdev

Shamelessly plundered from this course. It's meant to be used for driver modules. Inserts a module and creates an associated file in /dev

#!/bin/sh
# insdev <module> [params]
module=$1
shift
/sbin/insmod ./$module.ko $* || exit 1
rm -f /dev/$module
major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
mknod /dev/$module c $major 0
chmod 666 /dev/$module

Removing a module

rmmod
modprobe -r <module> [params]

rmdev

Shamelessly plundered from this course. It's meant to be used for driver modules. Removes a module but also deletes the associated file in /dev

#!/bin/sh
# rmdev <module>
module=$1
/sbin/rmmod $module || exit 1
rm -f /dev/$module 

Make a block o char file

mknod /dev/<name> <type> <major> <minor>

Modules loaded at boot time

You can find the list in /etc/modules.