I am just curious is there any way to determine if a particular module is loaded/installed.
$lsmod lists all modules (device driver loaded).
Is there any way to check or a command that returns true/false boolean output if a module name is polled. for eg. if keyboard.o exists return true else false. i need this tip to complete my driver auto refresh program.
PS: tried modinfo. i am using busybox client in my test DUT so can you give some alternatives other than modinfo ?
To list all currently loaded modules in Linux, we can use the lsmod (list modules) command which reads the contents of /proc/modules like this.
The lsmod command shows a list of the currently loaded kernel modules.
Modules are stored in /usr/lib/modules/kernel_release . You can use the command uname -r to get your current kernel release version.
The modinfo module
method does not work well for me. I prefer this method that is similar to the alternative method proposed:
#!/bin/sh MODULE="$1" if lsmod | grep "$MODULE" &> /dev/null ; then echo "$MODULE is loaded!" exit 0 else echo "$MODULE is not loaded!" exit 1 fi
not sure if modinfo modname
and checking $?
will work for you, just a suggestion.
/tmp$ sudo modinfo e1000 /tmp$ echo $? 0 /tmp$ sudo modinfo keyboard ERROR: modinfo: could not find module keyboard /tmp$ echo $? 1
alternatively you also grep /proc/modules
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With