Check information of kernel module on Linux

Every time a Linux system is booted, there are a number of kernel modules that will be loaded by the system and used to provide additional support for filesystems, new hardware, and many other things. Obtaining information about particular kernel modules may a be an important troubleshooting skill. In this tutorial, we will explain how to obtain module information such as description, dependency, author or relevant object file name using the modinfo command and its various options.

In this tutorial you will learn:

  • How to check the currently loaded Linux kernel
  • How to see which kernel modules are currently loaded
  • How to see detailed information about any loaded kernel module
Check information of kernel module on Linux
Check information of kernel module on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to check kernel module info with modinfo command




Any loadable kernel module is, by default, installed within the /lib/modules directory. For each particular kernel, a separate directory is created to contain modules to be used with that particular kernel:

$ ls /lib/modules/
5.15.0-25-generic  5.15.0-30-generic

From the output on our test system, we can see that this particular system has two kernels installed. It is typical for Linux systems to have an extra kernel or two remaining on the system, in case there is an error and it needs to fall back to an older version. But remember that only one kernel can be run at any given time.

We can see which kernel is currently in use with the uname command.

$ uname -a
Linux linuxconfig 5.15.0-30-generic #31-Ubuntu SMP Thu May 5 10:00:34 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

The above uname command output shows that 5.15.0-30-generic is the current system’s running kernel and thus modules loaded from /lib/modules/5.15.0-30-generic/ directory are in use. To list all currently loaded kernel modules, we can use the lsmod command:

$ lsmod
Output of the lsmod command, showing all currently loaded kernels
Output of the lsmod command, showing all currently loaded kernels

View info of loaded modules with modinfo

Now we will use the modinfo command to check information about our currently loaded kernel modules. Check out some of the examples below and note what the individual command options do.

  1. First, let’s get the general description of a particular module with the -d option:
    $ modinfo -d psmouse
    PS/2 mouse driver
    
  2. Next, let’s find out what is the actual object file location for this particular module with the -n option:
    $ modinfo -n psmouse
    /lib/modules/5.15.0-30-generic/kernel/drivers/input/mouse/psmouse.ko
    
  3. To see an object file location for any given installed Linux kernel, use the -k switch and specify the kernel name.
    $ modinfo -k 5.15.0-30-generic -n psmouse
    /lib/modules/5.15.0-30-generic/kernel/drivers/input/mouse/psmouse.ko
    
  4. Gather information about the module’s author by using the -a option.
    $ modinfo -a psmouse
    Vojtech Pavlik
    
  5. Lastly, to find a module’s dependency information, we can use the -F switch:
    $ modinfo -F depends ppdev
    parport
    

    Note that if nothing is returned in the output, then the module does not have any dependencies.




Checking kernel module information with the modinfo command on Linux
Checking kernel module information with the modinfo command on Linux

Closing Thoughts

In this tutorial, we saw how to check information about a kernel module on a Linux system. Since modules extend the functionality of our Linux system, and provide additional support for hardware and software, it is important for system administrators to know the basics of troubleshooting them. Now that you know how to check information about loaded kernel modules, check out our other tutorial on Basic Linux Kernel commands for module administration to learn how to load and unload kernel modules on Linux.



Comments and Discussions
Linux Forum