1. Overview

The lspci (List PCI) command is used in Linux to get a list of system PCI buses. In other words, lspci will display information about all the devices connected to the PCI subsystem.

In this tutorial, we’ll see how to use the lspci utility with various command options.

2. Installing the lspci Utility

The lspci utility belongs to the pciutils package and can be installed manually. The majority of Linux distributions come pre-installed with the pciutils package. However, we can manually install it by using apt:

$ sudo apt install pciutils

3. Syntax of the lspci Command

When executing the lspci command with no further options, we’ll see a list of all PCI buses and attached devices:

$ lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: VMware SVGA II Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service
00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC'97 Audio Controller (rev 01)
00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)

Now, here’s what we can learn from the lspci command output:

  • The first field (00:00.0) contains the PCI Bus number, device number, and function number of the device.
  • Terms like Host bridge, ISA bridge, and IDE Interface represent the type or class of a device attached to the PCI Bus.
  • The third field of the output is the combination of the Device Vendor name, Device name, its mode of operation, and revision number.

For instance, Intel Corporation is the Vendor, 440FX – 82441FX represents the Device name, [Natoma] is the mode of operation, and (rev 02) is the revision number.

4. General Usage

The lspci command can be used with different options to generate different output. Let’s see some examples of the different options we can use.

4.1. -m Option

The -m option lists the information about the PCI Buses in a machine-readable format. The format includes comma-separated field values that are easy to parse in shell scripts:

$ lspci -m
00:00.0 "Host bridge" "Intel Corporation" "440FX - 82441FX PMC [Natoma]" -r02 -p00 "" ""
00:01.0 "ISA bridge" "Intel Corporation" "82371SB PIIX3 ISA [Natoma/Triton II]" -p00 "" ""
00:01.1 "IDE interface" "Intel Corporation" "82371AB/EB/MB PIIX4 IDE" -r01 -p8a "" ""
00:02.0 "VGA compatible controller" "VMware" "SVGA II Adapter" -p00 "VMware" "SVGA II Adapter"
00:03.0 "Ethernet controller" "Intel Corporation" "82540EM Gigabit Ethernet Controller" -r02 -p00 "Intel Corporation" "PRO/1000 MT Desktop Adapter"
00:04.0 "System peripheral" "InnoTek Systemberatung GmbH" "VirtualBox Guest Service" -p00 "" ""
00:05.0 "Multimedia audio controller" "Intel Corporation" "82801AA AC'97 Audio Controller" -r01 -p00 "Dell" "82801AA AC'97 Audio Controller"
00:06.0 "USB controller" "Apple Inc." "KeyLargo/Intrepid USB" -p10 "" ""
00:07.0 "Bridge" "Intel Corporation" "82371AB/EB/MB PIIX4 ACPI" -r08 -p00 "" ""
00:0d.0 "SATA controller" "Intel Corporation" "82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode]" -r02 -p01 "" ""

In return, this command’s output format displays double quotation marks (“”) around each PCI Bus field.

4.2. -t Option

We often want to visualize how system devices are interrelated. Therefore, the -t option outputs the hierarchy of PCI devices in a tree format:

$ lspci -t
-[0000:00]-+-00.0
           +-01.0
           +-01.1
           +-02.0
           +-03.0
           +-04.0
           +-05.0
           +-06.0
           +-07.0
           \-0d.0

Now, let’s break down the output we’ve got in the tree format:

  • The root node (0000:00) consists of domain (0000) and PCI Bus number (00), which usually represents the primary PCI bus to which all the devices are connected to the motherboard.
  • Every child node of the tree denotes a system device linked to the primary PCI bus (00).
  • The format for each child node is +. where represents the ID of a device and denotes the function of a device on a primary bus 00.

For example, the numbers (00, 01, 02) represent different PCI devices on the primary bus, while the numbers (.0, .1) represent various functions of particular PCI devices.

4.3. -v Option

Furthermore, we can also use the lspci command to get in-depth information about devices attached to the PCI Buses. For that, we’re using the -v option:

$ lspci -v
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
    Flags: fast devsel
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
    Flags: bus master, medium devsel, latency 0
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01) (prog-if 8a [ISA Compatibility mode controller, supports both channels switched to PCI native mode, supports bus mastering])
    Flags: bus master, fast devsel, latency 64
    I/O ports at 01f0 [size=8]
    I/O ports at 03f4
    I/O ports at 0170 [size=8]
    I/O ports at 0374
    I/O ports at d000 [size=16]
    Kernel driver in use: ata_piix
    Kernel modules: pata_acpi
.....

In return, more detailed information regarding PCI devices is displayed.

The information includes the Programming (IDE) interface – in this case, prog-if 8a [VGA Controller] – along with its version and the subsystem field with the vendor name and device ID.

Moreover, details regarding the flags, I/O ports, kernel driver, and the list of kernel modules are also provided. Meanwhile, if we need to get more verbose output for the PCI devices, we can use the -vv option:

$ lspci -vv
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
    Control: I/O- Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
    Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
....

Here, the output is more detailed.

4.4. Get Information in Tag:Value Format

Sometimes, we want information regarding PCI devices in a JSON-like tag:value format. To do that, we must merge the machine-readable and verbose formats. Thus, we’re using the -vmm options in our command:

$ lspci -vmm
Slot:    00:00.0
Class:    Host bridge
Vendor:    Intel Corporation
Device:    440FX - 82441FX PMC [Natoma]
Rev:    02
ProgIf:    00
....

Finally, the output separately displays each device’s information in tag:value format.

4.5. -k Option

Each PCI device functions using a different kernel driver and modules. To examine these, we use the -k option:

$ lspci -k
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
    Kernel driver in use: ata_piix
    Kernel modules: pata_acpi
....

From the above output, we learn:

  • The Kernel driver in use field displays the name of the driver handling the particular PCI device.
  • The Kernel modules field specifies all possible drivers for managing the device other than the driver in use.

For instance, the Kernel driver in use for the PCI device (00:01.1) is ata_piix, while the Kernel module available for it is pata_acpi.

4.6. -n Option

Further, the -n option provides the PCI device information in a numeric format used for scripting and debugging:

$ lspci -n
00:00.0 0600: 8086:1237 (rev 02)
00:01.0 0601: 8086:7000
00:01.1 0101: 8086:7111 (rev 01)
00:02.0 0300: 15ad:0405
00:03.0 0200: 8086:100e (rev 02)
00:04.0 0880: 80ee:cafe
00:05.0 0401: 8086:2415 (rev 01)
00:06.0 0c03: 106b:003f
00:07.0 0680: 8086:7113 (rev 08)
00:0d.0 0106: 8086:2829 (rev 02)

Here, separate numeric information for each PCI device is displayed:

  • The first value combining three numbers (00:00.0) holds the bus, device, and function numbers, while the subsequent four-digit number after the space represents the class code for a particular PCI device.
  • In a tag:value format, the next four-digit number specifies the vendor ID (8086), while the four-digit number after the colon specifies the device ID (1237).
  • The last part in parentheses indicates each device’s revision number (rev 02).

Additionally, the -nn option displays the output in a more human-readable format:

$ lspci -nn
00:00.0 Host bridge [0600]: Intel Corporation 440FX - 82441FX PMC [Natoma] [8086:1237] (rev 02)
00:01.0 ISA bridge [0601]: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] [8086:7000]
00:01.1 IDE interface [0101]: Intel Corporation 82371AB/EB/MB PIIX4 IDE [8086:7111] (rev 01)
00:02.0 VGA compatible controller [0300]: VMware SVGA II Adapter [15ad:0405]
00:03.0 Ethernet controller [0200]: Intel Corporation 82540EM Gigabit Ethernet Controller [8086:100e] (rev 02)
....

As we can see, this output is much easier to understand.

4.7. –s Option

Sometimes, we want to filter the information about a specific PCI device without going through the whole list.

Here, the -s option allows us to do so by mentioning the bus number, device number, and function number as parameters:

$ lspci -s 00:00.0
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)

Consequently, a single line of output for the particular PCI device (00:00:0) includes its device class (Host Bridge), Vendor name (Intel Corporation), Device name (440FX—82441FX PMC), mode of operation (Natoma), and revision number (rev 02).

4.8. –d Option

Finally, we use the -d option to filter the specific PCI device information based on the device vendor name and ID:

$ lspci -d 8086:1237
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)

Thus, we can see the PCI device with vendor ID 8086 and device ID 1237 is displayed.

5. Conclusion

In this article, we’ve discussed the lspci command in detail. Naturally, the lspci command displays in-depth information about the devices attached to the PCI Subsystem and is used to visualize their interconnectedness.

First, we saw how to display PCI information in a machine-readable format, a tree-like structure, a tag:value format, and a numeric format. Afterward, we learned how to display device codes and kernel drivers.

Finally, we used the lspci command to get information for a specific PCI device.