How To Use Lspci Command In Linux.
In this tutorial, we will cover the lspci command syntax and show you different ways 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.
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:
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:
Display output in a backward-compatible machine-readable form.
Display output in a machine-readable form for easy parsing by scripts.
Display output as a tree diagram.
Display a verbose version of the output.
Display a very verbose version of the output.
Display all available information in the output.
Show kernel drivers and modules handling each device.
Display the standard part of the configuration space in a hexadecimal format.
Display the whole PCI configuration space in a hexadecimal format.
Display the extended PCI configuration space in a hexadecimal format.
Display numbers and addresses as seen by the cards instead of the kernel.
Always display PCI domain numbers.
Identify PCI devices by path through each bridge instead of by bus number.
Identify PCI devices by path through each bridge, showing both the bus and device number.
Display PCI vendor and device codes as numbers.
Display PCI vendor and device codes as both numbers and names.
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.
Use DNS to query the central PCI ID database even if a device is found in the local pci.ids file.
Only show devices in a specified domain.
Only show devices with the specified vendor, device, and class ID.
Read PCI ID information from a user-defined file.
Use a custom file to map PCI IDs handled by kernel modules.
Perform a thorough scan of all PCI devices.
Display the current command version.
Select a custom PCI access method.
Set a custom parameter for the PCI library.
Use direct hardware access via Intel configuration mechanism 1.
Use direct hardware access via Intel configuration mechanism 2.
Use a text file as a list of PCI devices.
Increase debug level of the PCI library.
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.
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:
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:
For example, looking up the same device as above, this time with the vendor and 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.