How to use the command 'modinfo' (with examples)
- Linux
- December 25, 2023
The ‘modinfo’ command is used to extract information about a Linux kernel module. It allows users to view various attributes of the kernel module such as the author, description, license, parameters, and filename. This command is helpful for troubleshooting and understanding the details of a kernel module.
Use case 1: List all attributes of a kernel module
Code:
modinfo kernel_module
Motivation: Sometimes, we may need to get a comprehensive overview of a kernel module, including all its attributes. This can help us understand its purpose, dependencies, and other important details.
Explanation: The ‘modinfo’ command is followed by the name of the kernel module we want to extract information about.
Example output:
filename: /lib/modules/5.4.0-81-generic/kernel/drivers/usb/serial/usbserial.ko
license: GPL v2
description: USB Serial Driver core
author: Greg Kroah-Hartman <greg@kroah.com>
parm: debug:Debug enabled or not (bool)
In the example output, we can see the filename, license, description, and author attributes of the ‘usbserial’ kernel module. Additionally, there is a parameter named ‘debug’ that can be modified.
Use case 2: List the specified attribute only
Code:
modinfo -F author|description|license|parm|filename kernel_module
Motivation: Sometimes, we may only be interested in a specific attribute of a kernel module, such as the author or description. This command allows us to extract the desired attribute without cluttering the output with unnecessary information.
Explanation: The ‘modinfo’ command is followed by the ‘-F’ flag, which specifies that we want to extract a specific attribute. The attributes can be separated by a pipe (’|’) character. The kernel module name is also provided at the end of the command.
Example output:
author: Greg Kroah-Hartman <greg@kroah.com>
description: USB Serial Driver core
license: GPL v2
filename: /lib/modules/5.4.0-81-generic/kernel/drivers/usb/serial/usbserial.ko
In the example output, we can see that only the author, description, license, and filename attributes are displayed. This can be useful when we only need specific information about a kernel module.
Conclusion:
The ‘modinfo’ command is a versatile tool for extracting information about Linux kernel modules. It provides a detailed overview of a module, including attributes like the author, description, license, and parameters. By using this command, users can gain insights into the purpose and functionality of various kernel modules, which can be helpful for troubleshooting and understanding the underlying system.