Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

lspci Cheatsheet

📅 2020-Nov-03 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cheatsheet, pci ⬩ 📚 Archive

lspci is the primary tool on Linux to get information about the PCI buses, bridges and devices on your system. I have primarily used lspci to find information about wired/wireless network adapters and graphics cards.

$ sudo apt install pciutils
$ lspci

I typically grep this output to find the specific type of devices I am looking for. For example, to find graphics cards I typically use:

$ lspci | grep -i vga
$ lspci | grep -i nvidia

Every output line of this command has information such as the domain/bus/device/function assigned to the device by the system/OS, the class of device and finally the vendor and device names looked up from the PCI ID database. Here is one example device output line:

ff:0b.0 System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 01)

[0000]: Domain. This is not shown when its value is 0x0000. Values are in the range 0x0000 - 0xFFFF.
ff: Bus. Values are in the range 0x00-0xFF.
0b: Device. Values are in the range 0x00-0x1F.
0: Function. Values are in the range 0x0-0x7.
System peripheral: Class of device. Other values I have seen are host bridge, PCI bridge, PIC,
                   USB controller, communication controller, ethernet controller, audio device,
                   ISA bridge, SATA controller, SMBus, VGA compatible controller, serial bus
                   controller, performance counters.
Intel Corporation Xeon E7 v4: Vendor and device name looked up from PCI ID database.
$ lspci -m

Here is an example output line showing the difference between the default and machine readable options:

ff:0b.0 System peripheral: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 (rev 01)

ff:0b.0 "System peripheral" "Intel Corporation" "Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1" -r01 "ASRock Incorporation" "Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1"
$ lspci -nn

Example output line:

ff:0b.0 System peripheral [0880]: Intel Corporation Xeon E7 v4/Xeon E5 v4/Xeon E3 v4/Xeon D R3 QPI Link 0/1 [8086:6f81] (rev 01)

8086: Vendor ID for Intel Corporation. (Isn't it cool that Intel's ID is 0x8086?)
6f81: Device ID.
$ lspci -d 8086:
$ lspci -d :6f81
$ lspci -k
$ lspci -t

Here is an example output showing that roots are buses and leaf nodes are devices:

-+-[0000:ff]-+-0b.0
             +-0b.1
             +-0b.2
             +-0b.3
             +-0c.0
             +-0c.1
             +-0c.2
             +-0c.3

[0000.ff]: Domain 0x0000 and bus 0.FF.
0b.0: Device 0x0B and function 0x0.

This device will list in the default output as ff:0b.0.
$ lspci -v
$ lspci -vv
$ lspci -vvv

Note that some of the capabilities of the devices may not be displayed for non-root users. To get all the information use sudo.

References:

Tried with: Ubuntu 18.04