- Linux pci device list
- OPTIONS
- PCILIB AND ITS OPTIONS
- lspci Command: What Is It and How to Use It
- How to Install lspci
- lspci Command Syntax
- lspci Command Options
- lspci Examples
- Display PCI Information in a Machine-Readable Format
- Display PCI Information as a Tree Diagram
- Display PCI Information in a Detailed Format
- Display PCI Information in the Tag:Value Format
- Display PCI Information for a Specific Device
- Display Device Codes
- Display Kernel Drivers
Linux pci device list
lspci is a utility for displaying information about all PCI buses in the system and all devices connected to them.
By default, it shows a brief list of devices. Use the options described below to request either a more verbose output or output intended for parsing by other programs.
If you are going to report bugs in PCI device drivers or in lspci itself, please include output of «lspci -vvx» or even better «lspci -vvxxx» (however, see below for possible caveats).
Some parts of the output, especially in the highly verbose modes, is probably intelligible only to experienced PCI hackers. For the exact definitions of the fields, please consult either the PCI specifications or the header.h and /usr/include/linux/pci.h include files.
Access to some parts of the PCI configuration space is restricted to root on many operating systems, so the features of lspci available to normal users are limited. However, lspci tries its best to display as much as available and mark all other information with text.
OPTIONS
-v Be verbose and display detailed information about all devices. -vv Be very verbose and display more details. This level includes everything deemed useful. -vvv Be even more verbose and display everything we are able to parse, even if it doesn’t look interesting at all (e.g., undefined memory regions). -n Show PCI vendor and device codes as numbers instead of looking them up in the PCI ID list. -x Show hexadecimal dump of the standard part of the configuration space (the first 64 bytes or 128 bytes for CardBus bridges). -xxx Show hexadecimal dump of the whole PCI configuration space. It is available only to root as several PCI devices crash when you try to read some parts of the config space (this behavior probably doesn’t violate the PCI standard, but it’s at least very stupid). However, such devices are rare, so you needn’t worry much. -xxxx Show hexadecimal dump of the extended (4096-byte) PCI configuration space available on PCI-X 2.0 and PCI Express buses. -b Bus-centric view. Show all IRQ numbers and addresses as seen by the cards on the PCI bus instead of as seen by the kernel. -t Show a tree-like diagram containing all buses, bridges, devices and connections between them. -s [[[[
PCILIB AND ITS OPTIONS
The PCI utilities use PCILIB (a portable library providing platform-independent functions for PCI configuration space access) to talk to the PCI cards. It supports the following access methods:
linux_sysfs The /sys filesystem on Linux 2.6 and newer. The standard header of the config space is available to all users, the rest only to root. Supports extended configuration space and PCI domains. linux_proc The /proc/bus/pci interface supported by Linux 2.1 and newer. The standard header of the config space is available to all users, the rest only to root. intel_conf1 Direct hardware access via Intel configuration mechanism 1. Available on i386 and compatibles on Linux, Solaris/x86, GNU Hurd and Windows. Requires root privileges. intel_conf2 Direct hardware access via Intel configuration mechanism 2. Available on i386 and compatibles on Linux, Solaris/x86 and GNU Hurd. Requires root privileges. Warning: This method is able to address only first 16 devices on any bus and it seems to be very unreliable in many cases. fbsd_device The /dev/pci device on FreeBSD. Requires root privileges. aix_device Access method used on AIX. Requires root privileges. nbsd_libpci The /dev/pci0 device on NetBSD accessed using the local libpci library.
By default, PCILIB uses the first available access method and displays no debugging messages, but you can use the following switches to control its behavior:
-P Force use of the linux_proc access method, using instead of /proc/bus/pci. -H1 Use direct hardware access via Intel configuration mechanism 1. -H2 Use direct hardware access via Intel configuration mechanism 2. -F Extract all information from given file containing output of lspci -x. This is very useful for analysis of user-supplied bug reports, because you can display the hardware configuration in any way you want without disturbing the user with requests for more dumps. -G Increase debug level of the library.
lspci Command: What Is It and How to Use It
The lspci (list PCI) Linux command displays information about each PCI bus on your system. This includes information about the devices connected to the PCI subsystem.
In this tutorial, we will cover the lspci command syntax and show you different ways to use it.
- A system running a Linux distribution.
- Access to an account with sudo privileges.
- Access to the terminal window or command line.
How to Install lspci
Start by updating the system repository to the latest version:
The lspci command is a part of the pciutils package. Pciutils is included in most Linux distributions by default.
If you want to install the pciutils package manually, use one of the following commands, depending on your Linux distribution:
- Ubuntu/Debian: sudo apt install pciutils
- RedHat/CentOS: sudo yum install pciutils
- Fedora: sudo dnf install pciutils
- Arch Linux: sudo pacman -S pciutils
lspci Command Syntax
The lspci command uses the following syntax:
Using the lspci command without any options produces an output similar to the following:
Let’s take the first line of the output:
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02)
The output above contains the following sections:
- 00:00.0 — The bus number, device number, and function number, in that order.
- Host bridge: — Device class.
- Intel Corporation — Device vendor.
- 440FX — 82441FX PMC — Device name.
- [Natoma] — Mode of operation.
- (rev 02) — Revision number.
lspci Command Options
The lspci command uses the following options:
Option | Description |
---|---|
-m | Display output in a backward-compatible machine-readable form. |
-mm | Display output in a machine-readable form for easy parsing by scripts. |
-t | Display output as a tree diagram. |
-v | Display a verbose version of the output. |
-vv | Display a very verbose version of the output. |
-vvv | Display all available information in the output. |
-k | Show kernel drivers and modules handling each device. |
-x | Display the standard part of the configuration space in a hexadecimal format. |
-xxx | Display the whole PCI configuration space in a hexadecimal format. |
-xxxx | Display the extended PCI configuration space in a hexadecimal format. |
-b | Display numbers and addresses as seen by the cards instead of the kernel. |
-D | Always display PCI domain numbers. |
-P | Identify PCI devices by path through each bridge instead of by bus number. |
-PP | Identify PCI devices by path through each bridge, showing both the bus and device number. |
-n | Display PCI vendor and device codes as numbers. |
-nn | Display PCI vendor and device codes as both numbers and names. |
-q | Use DNS to query the central PCI ID database if a device is not found in the local pci.ids file and save the result in the local cache. |
Use DNS to query the central PCI ID database if a device is not found in the local pci.ids file and reset the local cache. | |
-Q | Use DNS to query the central PCI ID database even if a device is found in the local pci.ids file. |
-s | Only show devices in a specified domain. |
-d | Only show devices with the specified vendor, device, and class ID. |
-i | Read PCI ID information from a user-defined file. |
-p | Use a custom file to map PCI IDs handled by kernel modules. |
-M | Perform a thorough scan of all PCI devices. |
—version | Display the current command version. |
-A | Select a custom PCI access method. |
-O | Set a custom parameter for the PCI library. |
-H1 | Use direct hardware access via Intel configuration mechanism 1. |
-H2 | Use direct hardware access via Intel configuration mechanism 2. |
-F | Use a text file as a list of PCI devices. |
-G | Increase debug level of the PCI library. |
lspci Examples
Here are some ways you can display the PCI device information using the lspci command.
Display PCI Information in a Machine-Readable Format
Use the -mm option to display the PCI information in a machine-readable format:
This output format adds double quotation marks ( « ) around each information category, making it easier to pass the data to a shell script.
Note: The -m option displays the data in a backward-compatible machine-readable format.
Display PCI Information as a Tree Diagram
Using the -t option displays the bus, device, and function numbers in a tree diagram, showing how they are connected:
Display PCI Information in a Detailed Format
The lspci command lets you set the level of detail to show in the output. Using the -v option displays the output in a verbose format, with in-depth information about all devices:
The -vv option shows the very verbose output:
The -vvv option shows the highest level of detail in the output:
Display PCI Information in the Tag:Value Format
Combining the verbose and machine-readable formats displays the output in the tag:value format:
The tag:value format lists PCI devices in a format similar to JSON, making the information easier to read. Each device is a separate section, with the information displayed in multiple lines:
Display PCI Information for a Specific Device
Using the -s option lets you display information for a device by providing the bus, device, and function number:
lspci -s [bus number]:[device number].[function number]
For instance, showing the information for the device at 00:00.0:
Another method is to use the vendor and device code with the -d option:
lspci -d [vendor code]:[device code]
For example, looking up the same device as above, this time with the vendor and device code:
Note: If you only have the vendor code or the device code for the device you want to look up, use lspci -d [vendor code]: or lspci -d :[device code] .
Display Device Codes
Using the -n option displays the vendor and device code for each PCI device:
The -nn option displays both the vendor and device codes and device names, making it easier to read the output:
The vendor and device codes are displayed in brackets at the end of each entry:
Display Kernel Drivers
Using the -k option displays a more detailed version of the output, including the kernel drivers and modules currently in use:
After reading this tutorial, you should be able to use the lspci command to look up information about the PCI devices connected to your system.
Learn more about using Linux commands in our Linux Commands Cheat Sheet.