Short Information about loaded kernel modules

2010-01-24 2 min read Linux

There are couple of ways you can find the information on the <a class="zem_slink" title="Loadable kernel module" rel="wikipedia" href="http://en.wikipedia.org/wiki/Loadable_kernel_module">loadable kernel modules. All these would always involve calling <a class="zem_slink" title="Lsmod" rel="wikipedia" href="http://en.wikipedia.org/wiki/Lsmod">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/2.6.31.5-127.fc12.i686.PAE/kernel/fs/fat/vfat.ko
author:         Gordon Chaffee
description:    <a class="zem_slink" title="File Allocation Table" rel="wikipedia" href="http://en.wikipedia.org/wiki/File_Allocation_Table">VFAT <a class="zem_slink" title="File system" rel="wikipedia" href="http://en.wikipedia.org/wiki/File_system">filesystem support
license:        <a class="zem_slink" title="GNU General Public License" rel="wikipedia" href="http://en.wikipedia.org/wiki/GNU_General_Public_License">GPL
srcversion:     48F6DF1D674F0E1325466C9
depends:        fat
vermagic:       2.6.31.5-127.fc12.i686.PAE 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="http://en.wikipedia.org/wiki/Grep">grep the required fields and susbstitute the end with <a class="zem_slink" title="Newline" rel="wikipedia" href="http://en.wikipedia.org/wiki/Newline">newline for the last patter <img style="vertical-align: bottom;" src="http://sc.webmessenger.msn.com/10.1.0323.0/session/images/emoticons/smile_regular.gif" 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="http://reblog.zemanta.com/zemified/e252418c-c6cf-4fd7-8e83-036dc2ce6de7/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_e31.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related pretty-attribution">

comments powered by Disqus