Bootstrap FreeKB - Linux Commands - lsmod (list loaded modules)
Linux Commands - lsmod (list loaded modules)

Updated:   |  Linux Commands articles

The lsmod command can be used to list all of the modules that are currently loaded in the kernel. The file for a certain module will be somewhere below the /lib/modules directory. The lsmod command will list many modules. In this example, the cdrom, floppy, and ip_tables modules are listed.

[john.doe@server1 ~]# lsmod
cdrom        42556  1  sr_mod
floppy       69417  0
ip_tables    27115  5  iptable_security,iptable_filter,iptable_mangle,iptable_nat,iptable_raw
. . .

 

Module name

The first field is the name of the module. In this example, the module names are cdrom, floppy, and ip_tables.

 

Memory

The second field is the amount of memory being used by the module. In this example, the cdrom module is using 42556 bytes of memory, the floppy module is using 69417 bytes of memory, and the ip_tables module is using 27115 bytes of memory.

 

Instances

The third and fourth fields list the number and name of other processes using the module. In this example, the cdrom module is being used by sr_mod, the floppy module is not being used, and the ip_tables module is being used by iptable_security,iptable_filter,iptable_mangle,iptable_nat, and iptable_raw.

 


List modules in alphabetical order

By default, the lsmod command will not list the modules in alphabetical order. The sort command can be used to list the modules in alphabetical order.

[john.doe@server1 ~]# lsmod | sort
arc4         12608  0
ata_generic  12910  0
ata_piix     35038  0
auth_rpcgss  59314  1  nfsd
. . .

 


List every module

The lsmod command will only list the modules currently loaded in the kernel. The system will contain many modules that are not currently loaded in the kernel. The find command can be used to locale modules that are not currently loaded in the kernel. In the prior example, the acpi module was not loaded in the kernel. The find command shows that acpi is available.

[john.doe@server1 ~]# find /lib/modules -name acpi
/lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/acpi

 

Similarly, the modinfo command can display detailed information about a module.

[john.doe@server1 ~]# modinfo -n acpi
filename:    /lib/modules/3.10.0-327.36.3.el7.x86_64/kernel/drivers/cpufreq/acpi-cpufreq.ko

 


View detailed information

The modinfo command can be used to get more detailed information about a module.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 3294f0 in the box below so that we can be sure you are a human.