Skip to content

lsmod

Show the status of modules in the Linux Kernel


List modules

lsmod

Example: Find bluetooth modules easy

lsmod |grep bt

Runtime Kernel Module Dependency List (Text-Only)

lsmod | awk 'NR==1{next} {
  if ($4 != "" && $4 != "-") {
    n=split($4,a,","); for(i=1;i<=n;i++) if(a[i]!="") print a[i] " -> " $1
  }
}'

Minimal Runtime Kernel Module Dependency View

lsmod | awk 'NR>1 && $4!="-" {
    print $1; split($4,a,",");
    for(i in a) print "  -> used by:", a[i]; print ""
}'

Print a module header followed by who uses it:

lsmod | awk '
NR==1 { next }          # skip header
{
    mod = $1
    used = $4

    if (used != "" && used != "-") {
        print mod
        n = split(used, a, ",")
        for (i = 1; i <= n; i++)
            if (a[i] != "")
                print "  -> used by:", a[i]
        print ""
    }
}
'

Reverse view: module depends on

lsmod | awk '
	NR==1 { next }
	{
	    mod = $1
	    used = $4
	    if (used != "" && used != "-") {
	        n = split(used, a, ",")
	        for (i = 1; i <= n; i++)
	            if (a[i] != "")
	                dep[a[i]] = dep[a[i]] mod " "
	    }
	}
	END {
	    for (m in dep) {
	        print m
	        split(dep[m], a, " ")
	        for (i in a)
	            if (a[i] != "")
	                print "  -> depends on:", a[i]
	        print ""
	    }
	}
'

Load module automatically at boot

echo "hp-wmi-sensors" > /etc/modules-load.d/hp-wmi-sensors.conf

,