lsmod

system informationLinux
The lsmod command is one of the most frequently used commands in Linux/Unix-like operating systems. lsmod Show the status of loaded kernel modules

Quick Reference

Command Name:

lsmod

Category:

system information

Platform:

Linux

Basic Usage:

lsmod [options] [arguments]

Common Use Cases

    Syntax

    lsmod

    Options

    Option Description
    --help, -h Display help information
    --version, -V Display version information

    The lsmod command has no specific options of its own as it simply displays the contents of /proc/modules in a formatted way.

    Examples

    How to Use These Examples

    The examples below show common ways to use the lsmod command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    lsmod
    Display all currently loaded kernel modules.
    # Advanced Examples Advanced
    lsmod | grep nvidia
    Filter the output to show only NVIDIA-related modules.
    lsmod | sort -k 2 -nr Sort modules by their size (largest first). lsmod | head -10 Show only the first 10 loaded modules. lsmod | awk '{print $1}' | sort List all module names in alphabetical order. lsmod | grep -v "^Module" | wc -l Count the number of loaded modules.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The 'lsmod' command is a utility for displaying information about loaded kernel modules in a Linux system. It reads data from the /proc/modules file and formats it in a more readable way, making it easier to see which modules are currently loaded and how they interact with each other. Key features of the lsmod command: 1. Module Listing: The primary function of lsmod is to show all kernel modules that are currently loaded into the running kernel. 2. Dependency Information: For each module, lsmod shows which other modules are using it, which is crucial for understanding module dependencies before attempting to unload a module. 3. Usage Count: The command displays how many instances or processes are currently using each module, indicating how widely used a particular module is. 4. Module Size: lsmod shows the memory footprint of each module in bytes, helping to understand the resource consumption of kernel modules. 5. Simple Interface: Unlike many other system utilities, lsmod has a straightforward interface with no options, making it easy to use for quick system checks. 6. Integration with Module Management: lsmod is part of the module-init-tools (or kmod in newer distributions), which includes other commands like modprobe, insmod, and rmmod for complete module management. The output of lsmod typically includes: - Module name: The name of the loaded kernel module - Size: The amount of memory the module is using (in bytes) - Used by: The number of modules or processes using this module - Used by list: Names of modules that depend on this module Common use cases for lsmod include: - Checking which hardware drivers are currently loaded - Troubleshooting hardware detection issues - Verifying if a specific module was loaded after installation - Understanding module dependencies before unloading modules - System auditing and documentation - Performance tuning by identifying unnecessary loaded modules lsmod is particularly useful for system administrators, kernel developers, and users who need to diagnose hardware-related issues or customize their kernel module configuration. Since kernel modules extend the functionality of the Linux kernel without requiring a system reboot, managing them effectively is an important aspect of Linux system administration, and lsmod provides the visibility needed for this task.

    Related Commands

    These commands are frequently used alongside lsmod or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the lsmod command works in different scenarios.

    $ lsmod
    View All Commands