Read PCI Hardware Safely with lspci
You will finish with a small set of repeatable commands for identifying PCI devices, matching them to kernel drivers, narrowing the result to one slot, and producing output that a script can parse. The examples use lspci 3.10.0 from pciutils 3.10.0-2build1.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about fifteen minutes. You need a shell and the pciutils package. The normal inspection commands are read-only and do not need elevated privileges. Some configuration-space dumps need root and can upset badly behaved hardware, so they are kept behind a clear warning.
1. Confirm the installed command
Check which binary your shell will run, then record its version. This avoids explaining output from a different installation:
$ command -v lspci
/usr/bin/lspci
$ lspci --version
lspci version 3.10.0
$ dpkg-query -W -f='${Package} ${Version}\n' pciutils
pciutils 1:3.10.0-2build1
--version is intended to be used by itself. If your package manager or distribution reports another version, expect names and detailed fields to vary slightly.
Checkpoint
You know the executable and version. Continue with ordinary user privileges.
2. Get the inventory first
Run lspci without options for the short inventory:
$ lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 05)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
00:14.0 USB controller: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller (rev 31)
00:17.0 SATA controller: Intel Corporation Q170/Q150/B150/H170/H110/Z170/CM236 Chipset SATA Controller [AHCI Mode] (rev 31)
Your list will be different. The value at the start is the PCI address, written as domain, bus, device and function when needed. On a machine with only domain 0, lspci normally hides the domain. Use -D when an address must be unambiguous:
$ lspci -D | head -n 3
0000:00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 05)
0000:00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
0000:00:14.0 USB controller: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller (rev 31)
The address is not a device file and it is not a command to change hardware. It is an identifier you can use with later selection options.
3. Add numeric IDs when names are not enough
Names come from the local PCI ID list and can be incomplete or stale. Add -nn to show the class, vendor and device numbers alongside their names:
$ lspci -nn | head -n 3
00:00.0 Host bridge [0600]: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers [8086:591f] (rev 05)
00:02.0 VGA compatible controller [0300]: Intel Corporation HD Graphics 630 [8086:5912] (rev 04)
00:14.0 USB controller [0c03]: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller [8086:a12f] (rev 31)
Use -n instead when you want numeric IDs without name lookups. The hexadecimal vendor and device pair, such as 8086:5912, is useful in a bug report or when comparing two hosts.
Do not use -q casually in automation. It may query the central PCI ID database over DNS and cache results in ~/.pciids-cache. Prefer the local result for repeatable scripts; investigate a missing name separately.
4. See the hardware relationship and driver
Use the tree view when a flat list hides which bridges connect devices:
$ lspci -t
-[0000:00]-+-00.0
+-02.0
+-14.0
+-17.0
\-1f.6
The exact branches depend on the host. For the driver and capable modules, use -k:
$ lspci -k | sed -n '1,12p'
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 05)
Subsystem: Fujitsu Technology Solutions Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers
Kernel driver in use: skl_uncore
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
Subsystem: Fujitsu Technology Solutions HD Graphics 630
Kernel modules: i915
"Kernel driver in use" identifies the driver handling that device now. "Kernel modules" lists modules that report they can handle it, which is not the same as a module being loaded or selected. A blank driver line can be a useful finding, not proof that the device is broken.
Checkpoint
You can identify a device, its numeric IDs, its place in the bus tree, and its current driver without changing system state.
5. Narrow a query to one device
Use -s with the address from the inventory. Components are hexadecimal. This example selects the VGA device at bus 0, device 2, function 0:
$ lspci -s 00:02.0 -nnk
00:02.0 VGA compatible controller [0300]: Intel Corporation HD Graphics 630 [8086:5912] (rev 04)
Subsystem: Fujitsu Technology Solutions HD Graphics 630
Kernel modules: i915
Use the form that matches the question: -s 0: selects bus 0, -s 00:02 selects all functions of that device, and -s 00:02.0 selects one function. Do not confuse a decimal-looking address with decimal input. PCI address components are hexadecimal.
You can also filter by IDs with -d. For example, this selects devices from vendor 8086:
$ lspci -d 8086: -nn
00:00.0 Host bridge [0600]: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers [8086:591f] (rev 05)
00:02.0 VGA compatible controller [0300]: Intel Corporation HD Graphics 630 [8086:5912] (rev 04)
The wildcard after the colon means any device ID from that vendor. Verify the address or ID from your own inventory before building a monitoring rule.
6. Produce output for a script
Human-oriented output can change between lspci versions. For a simple, shell-oriented record per device, use -m:
$ lspci -m | head -n 2
00:00.0 "Host bridge" "Intel Corporation" "Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers" -r05 -p00 "Fujitsu Technology Solutions" "Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers"
00:02.0 "VGA compatible controller" "Intel Corporation" "HD Graphics 630" -r04 -p00 "Fujitsu Technology Solutions" "HD Graphics 630"
For fielded records, use -mm. It separates records with blank lines and uses tags such as Slot, Class, Vendor, Device, Driver and Module. Parsers must ignore tags they do not recognise because later versions can add them. Add -n if your parser needs numeric IDs rather than names. Do not parse the ordinary default display unless you accept version-specific breakage.
7. Treat configuration dumps as a separate risk
-x reads the standard configuration-space area. The full-configuration-space form reads the whole area and is restricted to root on many systems; some devices can crash when the command reads parts of it. The extended form reads the 4096-byte area where supported.
Warning
These options are still described as reads, but they can have hardware consequences. Do not run them on a production host merely to collect more detail. If a driver report specifically asks for a dump, confirm the exact command, take a maintenance window, and prefer the least invasive level requested:
$ sudo lspci -s 00:02.0 -x
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
00: 86 80 12 59 07 00 00 00 04 00 00 03 00 00 00 00
The bytes and line count vary by device. There is no general undo command for a read, so recovery means stopping if the device behaves abnormally, recording the command and output, and following the hardware or vendor recovery procedure. Ordinary lspci, -nn, -t, -k and -mm do not alter PCI configuration.
Done means
- You confirmed the installed lspci and pciutils version.
- You can list devices and make domain numbers explicit when needed.
- You can identify numeric IDs, bus relationships and the active kernel driver.
- You can select one PCI address or vendor ID without guessing its syntax.
- You use
-mor-mmfor scripts instead of parsing display prose. - You know that configuration dumps are privileged, hardware-sensitive reads and have a reason before using them.