lspci - Linux


Overview

The lspci command in Linux is a utility used to display detailed information about all the PCI buses and devices on a system. It is primarily used to troubleshoot PCI devices and ensure that peripherals such as graphics cards, network adapters, and sound cards are configured properly. This tool is commonly used by system administrators and developers to diagnose hardware issues and configure systems for optimal performance.

Syntax

The basic syntax for the lspci command is:

lspci [options]

Options/Flags

lspci includes several options and flags that modify its output:

  • -v, --verbose: Shows detailed information about all devices.
  • -vv: Even more verbose. Shows very detailed information about all devices, useful for debugging.
  • -nn: Shows both the numerical ID and the name of the devices and vendors.
  • -k: Shows the kernel driver handling each device.
  • -t: Shows a tree-like diagram of all the devices.
  • -m: Displays the output in a machine-readable format for parsing by other programs.
  • -i: Allows specifying a different database file for the vendor and device information.
  • -s: Displays information about a specific device. Format must be [bus]:[slot]:[func].

Examples

  1. Basic Device Listing

    lspci
    

    This simple command will list all PCI devices on the system.

  2. Verbose Output

    lspci -v
    

    Use this command to get more detailed information about each device.

  3. Show Kernel Drivers

    lspci -k
    

    This command lists each PCI device along with the kernel driver managing it.

  4. Filtered Output by Device

    lspci -s 02:00.0
    

    Replace 02:00.0 with the actual bus and slot number to view details about a particular device.

Common Issues

  • Incorrect Device Information: Outdated hardware databases can lead to incorrect or incomplete device information. Updating the PCI ID database (update-pciids) can usually resolve this.
  • Permission Denied: Running lspci without sufficient privileges may result in limited output; use sudo lspci to get complete information.

Integration

lspci is often used in combination with other tools for comprehensive system diagnostics:

  • Piping with grep: To find a specific device, such as a network card:
    lspci | grep -i network
    
  • Scripting Usage: Incorporate lspci in scripts to check hardware before software deployment.
  • lsusb: List USB devices, similar in purpose for USB as lspci is for PCI devices.
  • lsblk: Lists information about block devices.

For more detailed information, the Linux man pages (man lspci) are an excellent resource. Alternatively, many distributions host their man pages online for ease of access.