lspci Command in Linux



The lspci command in Linux is a powerful tool used to display information about all PCI (Peripheral Component Interconnect) buses and devices in the system. This command is invaluable for system administrators and developers who need to troubleshoot hardware issues, gather system information, or configure hardware components.

Moreover, lspci can be particularly useful in environments where multiple PCI devices are used, such as in servers or workstations with various expansion cards.

Table of Contents

Here is a comprehensive guide to the options available with the lspci command −

Understanding lspci Command

The lspci command in Linux is a powerful utility used to display detailed information about all PCI (Peripheral Component Interconnect) buses and devices in the system. This command is particularly useful for system administrators and developers who need to troubleshoot hardware issues, gather system information, or configure hardware components.

PCI is a hardware bus used for adding internal components to a desktop computer. Devices connected via PCI include network cards, sound cards, modems, and graphics cards. The lspci command lists all PCI devices and provides detailed information about each one, such as the device type, vendor, and model.

Syntax of lspci Command

The basic syntax for the lspci command is −

lspci [options]

Without any options, the command lists all PCI devices in the system.

lspci Command Options

Here are some of the most commonly used options with the lspci command −

Options Descriptions
-vv Very verbose output. Provides even more detailed information.
-k Show kernel drivers handling each device and also kernel modules capable of handling it.
-t Show a tree view of the devices.
-nn Show numeric IDs.
-s [bus:slot.func] Show only devices in the specified slot.
-v Verbose output. Provides detailed information about each device.
-d [vendor:device] Show only devices with the specified vendor and device ID.
-x Show hex dump of the standard part of the configuration space.
-xxxx Show hex dump of the extended configuration space.
-b Bus-centric view. Show PCI bus addresses instead of domain:bus:slot.func.
-i [file] Use specified file as the PCI ID database.
-m Produce machine-readable output.
-M Enable bus mapping mode.

How to Use lspci Command in Linux?

By running lspci, users can see a list of all PCI devices present, along with their respective bus numbers, device IDs, and vendor information. This information is crucial for diagnosing connectivity issues, ensuring that devices are correctly recognized by the system, and verifying that the appropriate drivers are installed.

The -k option shows the kernel drivers handling each device, which can be helpful for identifying driver-related issues. The -t option displays a tree view of the devices, showing the hierarchy and relationships between them. These options make lspci a versatile tool for managing and troubleshooting PCI devices, offering detailed insights that are essential for maintaining system stability and performance.

Examples of lspci Command in Linux

Let's explore some practical examples to understand how to use the lspci command effectively.

List All PCI Devices

This command lists all PCI devices in the system. The output includes columns like 00:00.0, which represents the bus, slot, and function of the device, followed by the device description −

lspci
lspci Command in Linux1

Verbose Output

This command provides detailed information about each PCI device, including the device's capabilities and configuration −

lspci -v
lspci Command in Linux2

Very Verbose Output

This command provides even more detailed information about each PCI device, including additional capabilities and configuration details −

lspci -vv
lspci Command in Linux3

Show Kernel Drivers

This command shows the kernel drivers handling each PCI device and also lists kernel modules capable of handling the device −

lspci -k
lspci Command in Linux4

Tree View

This command displays a tree view of the PCI devices, showing the hierarchy and relationships between devices −

lspci -t
lspci Command in Linux5

Show Numeric IDs

This command displays the numeric vendor and device IDs along with the device description −

lspci -nn
lspci Command in Linux6

Show Specific Slot

Replace 00:1f.2 with the actual bus, slot, and function to display information about a specific PCI device −

lspci -s 00:1f.2
lspci Command in Linux7

Show Specific Vendor and Device

Replace 8086:1237 with the actual vendor and device ID to display information about a specific PCI device −

lspci -d 8086:1237
lspci Command in Linux8

Hex Dump of Configuration Space

This command displays a hex dump of the standard part of the configuration space for each PCI device −

lspci -x
lspci Command in Linux9

Hex Dump of Whole Configuration Space

This command displays a hex dump of the standard part of the configuration space for each PCI device −

lspci -xxx
lspci Command in Linux10

Hex Dump of Extended Configuration Space

This command displays a hex dump of the extended configuration space for each PCI device −

lspci -xxxx
lspci Command in Linux11

Bus-Centric View

This command displays PCI bus addresses instead of domain:bus:slot.func −

lspci -b
lspci Command in Linux12

Use Custom PCI ID Database

Replace /path/to/pci.ids with the path to a custom PCI ID database file −

lspci -i /path/to/pci.ids
lspci Command in Linux13

Machine-Readable Output

This command produces machine-readable output, which can be useful for scripting and automation −

lspci -m
lspci Command in Linux14

Enable Bus Mapping Mode

This command enables bus mapping mode, which can be useful for debugging and advanced troubleshooting −

lspci -M
lspci Command in Linux15

For more detailed information, you can refer to the official lspci documentation.

Conclusion

The lspci command is an essential tool for anyone working with Linux systems, providing detailed information about PCI devices and their configurations. In addition to basic device listing, the lspci command offers several options to enhance its functionality. For example, using the -v option provides verbose output, displaying more detailed information about each device, such as its capabilities and configuration.

By mastering the various options and examples provided in this guide, you'll be well-equipped to leverage the full power of the lspci command in your daily tasks. Whether you're troubleshooting hardware issues, gathering system information, or configuring hardware components, lspci is a versatile and invaluable tool in your Linux toolkit.

Advertisements