Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why do these two commands return different results?

lsmod | wc -l

ls /sys/module | wc -l
share|improve this question

lsmod lists all of your dynamic modules that are loaded.

The entries in /sys/module correspond to dynamic modules and modules which are built into the kernel (and have parameters that need to be accessible) rather than loaded dynamically. For example:

[michael@brazzers:~]$ ls -d /sys/module/ip_tables/
[michael@brazzers:~]$ lsmod |grep ^ip_tables
ip_tables              26995  3 iptable_filter,iptable_mangle,iptable_nat
[michael@brazzers:~]$ grep CONFIG_NF_NAT_IPV4 /boot/config-3.8.0-30-generic

You can see here that the iptables module is configured as a dynamic module. Contrast to:

[michael@brazzers:~]$ ls -d /sys/module/apparmor/
[michael@brazzers:~]$ lsmod |grep ^apparmor
[michael@brazzers:~]$ grep APPARMOR /boot/config-3.8.0-30-generic 

whereas apparmor is built-in.

share|improve this answer
@MikeB when you see CONFIG_X_X=yes i think that means the code is builting in the kernel not as dinamic module: Example grep EXT4 /boot/config-3.6.11-4.fc16.i686 CONFIG_EXT4_FS=y modinfo ext4 ERROR: Module ext4 not found ls -l /sys/module/ext4 ls: cannot access /sys/module/ext4: No such file or directory – c4f4t0r Sep 19 '13 at 18:15
Yes, it looks as though built-in modules need to have parameters for them to be visible. – MikeyB Sep 19 '13 at 18:48
  • /sys/module/MODULENAME

MODULENAME is the name of the module that is in the kernel. This module name will always show up if the module is loaded as a dynamic module. This is exactly what you can see when you issue lsmod command or when you check /proc/modules file.

If it is built directly into the kernel it will only show up if it has a version or at least one parameter. The available parameters are then available in the directory:

  • /sys/module/MODULENAME/parameters
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.