Short Information about loaded kernel modules

2010-01-24 386 words 2 mins read

There are couple of ways you can find the information on the <a class="zem_slink" title="Loadable kernel module" rel="wikipedia" href="">loadable kernel modules. All these would always involve calling <a class="zem_slink" title="Lsmod" rel="wikipedia" href="">lsmod to get the loaded kernel modules and then calling modinfo to get the info on the loaded modules. I will show you with examples:

$ lsmod
Module                  Size  Used by
cdc_acm                19616  0
vfat                    8744  9
fat                    41836  1 vfat

The above output is for the list of the modules loaded on the kernel.

$ modinfo vfat

filename:       /lib/modules/
author:         Gordon Chaffee
description:    <a class="zem_slink" title="File Allocation Table" rel="wikipedia" href="">VFAT <a class="zem_slink" title="File system" rel="wikipedia" href="">filesystem support
license:        <a class="zem_slink" title="GNU General Public License" rel="wikipedia" href="">GPL
srcversion:     48F6DF1D674F0E1325466C9
depends:        fat
vermagic: SMP mod_unload 686

modinfo will list the filename, authour and other related info for the modules. So if you wanted to get the info for all the modules, then the easiest way would be to do :

lsmod|xargs modinfo

But as you can see, this will list all the info on  the module, which is not really required. So there were couple of posts on commandlinefu, that takes care of displaying only the required information, viz. filename, authour and dependency. Here are the commands:

lsmod | sed &#8217;1d&#8217; | cut -d&#8217; &#8217; -f1 | xargs modinfo | egrep &#8217;^file|^desc|^dep&#8217; | sed -e&#8217;/^dep/s/$/\n/g&#8217;

Quite raw method where we <a class="zem_slink" title="Grep" rel="wikipedia" href="">grep the required fields and susbstitute the end with <a class="zem_slink" title="Newline" rel="wikipedia" href="">newline for the last patter <img style="vertical-align: bottom;" src="" alt=":)" />

lsmod | sed -e &#8217;1d&#8217; -e &#8217;s/\(\([^ ]*\) \)\{1\}.*/\2/&#8217; | xargs modinfo | sed -e &#8217;/^dep/s/$/\n/g&#8217; -e &#8217;/^file/b&#8217; -e &#8217;/^desc/b&#8217; -e &#8217;/^dep/b&#8217; -e d

Quite same as above with only exception of using one sed command rather than egrep and sed.

modinfo $(cut -d&#8217; &#8217; -f1 /proc/modules) | sed &#8217;/^dep/s/$/\n/; /^file\|^desc\|^dep/!d&#8217;

Directly using the modinfo commands without xargs and passing the arguments with cut command and then using sed to display only the required fields.

awk '{print $1}&#8217; &#8221;/proc/modules&#8221; | xargs modinfo | awk &#8217;/^(filename|desc|depends)/&#8217;

using awk to check the /proc/modules and then displaying the fields with awk<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href=""><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related pretty-attribution">


Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it