2 Methods to Get Loaded Linux Modules

2 Methods to Get Loaded Linux Modules

When working with Linux systems, understanding which modules are currently loaded into the kernel is important for troubleshooting, optimizing system performance, or customizing hardware support. This tutorial provides 2 methods how to get loaded Linux modules.

Method 1 - /proc/modules file

The /proc/modules file provides detailed information about loaded modules. To extract just the module names, run the following command:

cut -d' ' -f1 /proc/modules

Output example:

tls
intel_rapl_msr
intel_rapl_common
intel_uncore_frequency_common
intel_pmc_core
intel_vsec
pmt_telemetry
pmt_class
rapl
...

Let's break down the command step by step:

  • cut - is the command line tool to extract specific sections of text from input.
  • -d' ' - specifies a space as the delimiter.
  • -f1 - selects the first field, which corresponds to the module name.

Method 2 - lsmod command

The lsmod command provides a tabular overview of loaded modules. To extract only the module names, you can filter its output using awk:

lsmod | awk 'NR > 1 {print $1}'

Let's break down the command step by step:

  • lsmod - this command is used to list currently loaded kernel modules.
  • awk - is the command line tool, which is used to process text data line by line.
  • NR > 1 - skips first row which header.
  • print $1 - extracts the first column, which contains the module names.

Leave a Comment

Cancel reply

Your email address will not be published.