← All guides

lshw: Check Detailed Hardware Information on Linux

Updated:

lshw: Check Detailed Hardware Information on Linux

Configure automated checks to check detailed hardware information on your Linux server? Need to monitor system configuration and detect hardware changes aut...

Why Monitoring System Hardware Information Matters

Monitoring hardware information on your Linux server is crucial for system management, troubleshooting, and security. Hardware changes can indicate unauthorized modifications, component failures, or upgrades. Regular hardware monitoring helps maintain accurate system inventories, detect hardware issues early, plan capacity upgrades, and ensure system integrity.

Method 1: Basic Hardware Information with lshw

The lshw (list hardware) command provides detailed information about all hardware components on your Linux system. This tool requires root privileges to access complete hardware information.

Install lshw

First, ensure lshw is installed:

# Install lshw on Debian/Ubuntu
sudo apt-get install lshw

# Install lshw on CentOS/RHEL
sudo yum install lshw

Show All Hardware Information

To see complete hardware information:

# Show all hardware information (detailed)
sudo lshw

# Short hardware summary
sudo lshw -short

# Show hardware in HTML format
sudo lshw -html > hardware.html

Show Specific Hardware Classes

To focus on specific hardware components:

# Show disk information
sudo lshw -class disk

# Show network interfaces
sudo lshw -class network

# Show memory information
sudo lshw -class memory

# Show processor information
sudo lshw -class processor

Method 2: Monitor Hardware Changes Over Time

To detect unauthorized hardware changes, compare hardware information over time. This helps identify when components are added, removed, or replaced.

Save Current Hardware Configuration

# Save hardware information to file
sudo lshw -short > /tmp/hardware-$(date +%Y%m%d).txt

# Save hardware in JSON format
sudo lshw -json > /tmp/hardware-$(date +%Y%m%d).json

Compare Hardware Configurations

# Compare two hardware snapshots
diff /tmp/hardware-old.txt /tmp/hardware-new.txt

# Find differences in hardware
comm -23 <(sort /tmp/hardware-old.txt) <(sort /tmp/hardware-new.txt)

Method 3: Automated Hardware Monitoring with Zuzia.app

Manual checks work while you are looking. To keep running them without you, Zuzia uses its agent and scheduled tasks.

How it works in Zuzia

  • Install the Zuzia agent on the server with one command. CPU, RAM, disk, load and network metrics start reporting on their own, with alerts on a threshold, on drift from the server's normal, or on a disk fill-up forecast.
  • Save the commands from this guide as a scheduled task and choose how often it runs, from every minute to once a year. The agent runs it on every host you pick.
  • If a command fails, you get an alert right away by email, Slack, Discord, push (through your Pushover account) or SMS (through your Vonage account).
  • The output of every run is kept, so you can look back at what changed. On paid plans, AI can read the output and alert you only when it spots a problem.

Setting it up

  1. Add the server in the Zuzia dashboard and install the agent.
  2. Create a scheduled task with the check commands below, then choose the hosts and how often it runs.
  3. Choose your notification channels. Turn on maintenance mode during planned work so it doesn't trigger alerts.

Method 4: Advanced Hardware Monitoring Techniques

Get Hardware Serial Numbers

To track specific hardware components:

# Show hardware with serial numbers
sudo lshw -sanitize | grep -E "serial|product"

# Show disk serial numbers
sudo lshw -class disk | grep -E "serial|product"

Check Hardware Capabilities

To see hardware capabilities and features:

# Show processor capabilities
sudo lshw -class processor | grep -E "capabilities|features"

# Show network interface capabilities
sudo lshw -class network | grep -E "capabilities|features"

Export Hardware Information

For documentation and inventory:

# Export to HTML
sudo lshw -html > hardware-inventory.html

# Export to JSON
sudo lshw -json > hardware-inventory.json

# Export to XML
sudo lshw -xml > hardware-inventory.xml

Real-World Use Cases for Hardware Monitoring

Hardware Inventory Management

For maintaining accurate hardware inventories:

# Generate hardware inventory
sudo lshw -short > hardware-inventory-$(date +%Y%m%d).txt

# Save hardware information for asset management
sudo lshw -json > assets-$(hostname)-$(date +%Y%m%d).json

Troubleshooting Hardware Issues

When troubleshooting hardware problems:

# Check specific hardware component
sudo lshw -class disk | grep -A 20 "problematic-disk"

# Compare hardware before and after issue
diff hardware-before.txt hardware-after.txt

Security Auditing

For security audits, check for unauthorized hardware:

# Monitor USB devices
sudo lshw -class bus | grep -i usb

# Check network interfaces
sudo lshw -class network

Best Practices for Hardware Monitoring

1. Monitor Hardware Regularly

Check hardware information once weekly or monthly. Hardware configuration rarely changes unless components are added or removed, so frequent checks are usually unnecessary.

2. Maintain Baseline Hardware Snapshots

Keep baseline hardware snapshots for comparison. Update baselines after authorized hardware changes to reduce false positives.

3. Set Up Automated Alerts

Configure Zuzia.app to alert you immediately when hardware configuration changes. This ensures you're aware of unauthorized hardware modifications quickly.

4. Document Authorized Changes

Document all authorized hardware changes to help distinguish between legitimate and suspicious modifications.

5. Use Multiple Monitoring Methods

Combine lshw with other tools like dmidecode and lspci for comprehensive hardware monitoring.

Troubleshooting Common Hardware Monitoring Issues

lshw Command Not Found

If lshw is not installed:

# Install on Debian/Ubuntu
sudo apt-get install lshw

# Install on CentOS/RHEL
sudo yum install lshw

Insufficient Privileges

lshw requires root privileges for complete information:

# Use sudo for full access
sudo lshw

# Or run as root
sudo su -c "lshw"

Hardware Not Detected

If hardware is not detected:

  1. Check if hardware is properly connected
  2. Verify kernel modules are loaded: lsmod
  3. Check system logs: dmesg | tail -50
  4. Try alternative tools: lspci, lsusb, dmidecode

FAQ: Common Questions About Checking Hardware Information

How often should I check hardware information?

We recommend checking hardware information once weekly or monthly. Hardware configuration rarely changes unless components are added or removed, so frequent checks are usually unnecessary. Use Zuzia.app automated monitoring to check hardware periodically without manual intervention.

What if hardware configuration changes?

You'll receive notifications when hardware configuration changes are detected through Zuzia.app. This could indicate hardware additions, removals, or replacements that need verification. Review the changes and confirm they are authorized.

Can I check specific hardware components?

Yes, you can use lshw -class to check specific hardware classes such as disk, network, memory, or processor. For example: sudo lshw -class disk shows only disk-related hardware information.

How do I detect unauthorized hardware changes?

Set up automated monitoring in Zuzia.app that compares current hardware lists with baseline lists. Any hardware in the current list that isn't in the baseline indicates new hardware that should be investigated.

Can I track hardware serial numbers?

Yes, use sudo lshw -sanitize | grep serial to see hardware serial numbers. This helps track specific hardware components and maintain accurate inventories.

How can I monitor hardware across multiple servers?

Zuzia.app allows you to add multiple servers and monitor hardware information across all of them simultaneously. Each server executes commands independently, and all results are stored in Zuzia.app's database for centralized monitoring and analysis.

Does Zuzia.app use AI to analyze hardware patterns?

On paid plans, AI can read the output of your scheduled tasks and commands, explain it in plain language and alert you only when it spots a problem. Metric alerts work without AI: Zuzia alerts when CPU, RAM or load drifts from the server's normal and forecasts when a disk will fill up.

Related guides, recipes, and problems

  • Related guides

    • Complete server resource and hardware monitoring: guides--server-resource-monitoring-complete-guide.md
    • Linux server monitoring best practices: guides--linux-server-monitoring-best-practices.md
  • Related recipes

    • Detailed disk health and SMART status: recipes--check-disk-smart-health-status.md
    • Check disk space and filesystem usage: recipes--check-disk-space-mounted-filesystems.md, recipes--how-to-check-disk-usage-linux.md
    • Monitor system kernel version and uptime/load: recipes--monitor-system-kernel-version.md, recipes--monitor-system-load-average-uptime.md, recipes--monitor-system-uptime-load-average.md
  • Related problems

    • High disk I/O and disk-related performance issues: problems--high-disk-io-performance-impact.md
    • Server slow performance and capacity bottlenecks: problems--server-slow-performance-issues.md

We use cookies to ensure the proper functioning of our website.