lshw

system informationLinux
The lshw command is one of the most frequently used commands in Linux/Unix-like operating systems. lshw List hardware information

Quick Reference

Command Name:

lshw

Category:

system information

Platform:

Linux

Basic Usage:

lshw [options] [arguments]

Common Use Cases

    Syntax

    lshw [options]

    Options

    Option Description
    -short Show a short summary of the hardware tree
    -class CLASS Show only specified class of hardware (e.g., disk, network, memory)
    -C CLASS Same as -class CLASS
    -businfo Show bus information and hardware paths
    -json Output hardware tree as JSON
    -html Output hardware tree as HTML
    -xml Output hardware tree as XML
    -sanitize Hide sensitive information (serial numbers, etc.)
    -numeric Output numeric IDs (for PCI, USB, etc.)
    -quiet Don't display status messages
    -disable TEST Disable a test (like pci, isapnp, cpuid, etc.)
    -enable TEST Enable a test (like pci, isapnp, cpuid, etc.)
    -version Display version information
    -help Display help information

    Examples

    How to Use These Examples

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

    # Basic Examples Basic
    sudo lshw
    Display all hardware information (requires root privileges).
    sudo lshw -short
    Display a brief summary of hardware information.
    # Advanced Examples Advanced
    sudo lshw -class disk Display information about disk devices only. sudo lshw -class network Display information about network interfaces only. sudo lshw -json Output hardware information in JSON format. sudo lshw -html > hardware.html Generate an HTML report of hardware information. sudo lshw -class processor,memory Display information about processors and memory. sudo lshw -C display Show information about the graphics hardware. sudo lshw -businfo Show bus information and hardware paths. sudo lshw -sanitize Hide sensitive information like serial numbers.

    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 'lshw' (list hardware) command is a comprehensive utility for extracting detailed information about the hardware configuration of a Linux system. It provides in-depth details about various hardware components including the CPU, memory, disk drives, network adapters, USB controllers, and more. Key features of the lshw command: 1. Comprehensive Hardware Discovery: lshw detects and reports on virtually all hardware components present in the system, providing a complete inventory. 2. Hierarchical Display: By default, lshw shows hardware in a hierarchical tree structure, reflecting the physical and logical organization of components. 3. Multiple Output Formats: The command supports various output formats including text (default), HTML, XML, and JSON, making it suitable for both human reading and automated processing. 4. Component Filtering: Users can filter output to focus on specific hardware classes (such as disk, network, memory), which is useful when troubleshooting specific components. 5. Detailed Technical Information: lshw provides extensive technical details for each component, including model names, capacities, speeds, capabilities, and configuration settings. 6. Bus Information: The command can show how devices are connected to the system through various buses (PCI, USB, etc.), which helps understand the system architecture. 7. Privacy Protection: The -sanitize option allows hiding sensitive information like serial numbers when sharing the output for support purposes. Common use cases for lshw include: - System inventory and documentation - Troubleshooting hardware issues - Verifying hardware specifications - Checking for driver compatibility - Asset management and tracking - System reporting for IT departments - Automated hardware discovery in scripts It's important to note that lshw typically requires root privileges (sudo) to provide complete information, as accessing some hardware details requires elevated permissions. Without root access, the command will still work but may provide incomplete information. lshw is particularly valuable in server environments, where it helps administrators understand complex hardware configurations without needing physical access to the machine. It's also useful when preparing for hardware upgrades, as it provides the current specifications needed to determine compatibility with new components. While similar to commands like 'hwinfo' and 'dmidecode', lshw offers a good balance between comprehensiveness and usability, making it a standard tool in the Linux system administrator's toolkit.

    Related Commands

    These commands are frequently used alongside lshw 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 lshw command works in different scenarios.

    $ lshw
    View All Commands