lspci Command: What Is It and How to Use It

March 10, 2022

Introduction

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.

lspci Command: What Is It & How to Use It

Prerequisites

How to Install lspci

Start by updating the system repository to the latest version:

sudo apt update

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:

lspci [options]

Using the lspci command without any options produces an output similar to the following:

The lspci command default output

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:

OptionDescription
-mDisplay output in a backward-compatible machine-readable form.
-mmDisplay output in a machine-readable form for easy parsing by scripts.
-tDisplay output as a tree diagram.
-vDisplay a verbose version of the output.
-vvDisplay a very verbose version of the output.
-vvvDisplay all available information in the output.
-kShow kernel drivers and modules handling each device.
-xDisplay the standard part of the configuration space in a hexadecimal format.
-xxxDisplay the whole PCI configuration space in a hexadecimal format.
-xxxxDisplay the extended PCI configuration space in a hexadecimal format.
-bDisplay numbers and addresses as seen by the cards instead of the kernel.
-DAlways display PCI domain numbers.
-PIdentify PCI devices by path through each bridge instead of by bus number.
-PPIdentify PCI devices by path through each bridge, showing both the bus and device number.
-nDisplay PCI vendor and device codes as numbers.
-nnDisplay PCI vendor and device codes as both numbers and names.
-qUse 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.
-qqUse 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.
-QUse DNS to query the central PCI ID database even if a device is found in the local pci.ids file.
-sOnly show devices in a specified domain.
-dOnly show devices with the specified vendor, device, and class ID.
-iRead PCI ID information from a user-defined file.
-pUse a custom file to map PCI IDs handled by kernel modules.
-MPerform a thorough scan of all PCI devices.
--versionDisplay the current command version.
-ASelect a custom PCI access method.
-OSet a custom parameter for the PCI library.
-H1Use direct hardware access via Intel configuration mechanism 1.
-H2Use direct hardware access via Intel configuration mechanism 2.
-FUse a text file as a list of PCI devices.
-GIncrease 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:

lspci -mm
Displaying the PCI device 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:

lspci -t
Displaying the PCI device information as a tree diagram

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:

lspci -v
Displaying the PCI device information in a verbose format

The -vv option shows the very verbose output:

lspci -vv
Displaying the PCI device information in a very verbose format

The -vvv option shows the highest level of detail in the output:

lspci -vvv

Display PCI Information in the Tag:Value Format

Combining the verbose and machine-readable formats displays the output in the tag:value format:

lspci -vmm

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:

Displaying the PCI device information in the tag:value format

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:

lspci -s 00:00.0
Looking up a PCI device using the bus, device, and function number

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:

lspci -d 8086:1237
Looking up a PCI device using 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:

lspci -n
Displaying the vendor and device codes for PCI devices

The -nn option displays both the vendor and device codes and device names, making it easier to read the output:

lspci -nn

The vendor and device codes are displayed in brackets at the end of each entry:

Displaying the vendor and device codes  and device names for PCI devices

Display Kernel Drivers

Using the -k option displays a more detailed version of the output, including the kernel drivers and modules currently in use:

lspci -k
Displaying the kernel driver and module information for PCI devices

Conclusion

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.

Was this article helpful?
YesNo
Aleksandar Kovačević
With a background in both design and writing, Aleksandar Kovacevic aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
How to Use the dmesg Linux Command
January 18, 2022

The dmesg utility allows you to inspect the kernel ring buffer and check for errors during system startup. This tutorial shows how to use the dmesg command.
Read more
How to Use the ulimit Linux Command
December 9, 2021

The ulimit shell command allows you to view or limit the amount of resources a user can consume. Limiting resources prevents adverse effects in the system...
Read more
Using the Linux free Command
December 29, 2021

The free command in Linux is a utility that helps monitor RAM usage on a system. This guide shows how to use the free command and determine if there are enough resources for running new apps.
Read more
How to Use Linux nohup Command
December 16, 2021

Learn how to use the nohup command to continue running commands and processes in Linux even after the shell closes.
Read more