How Do I Check What PCI Devices Are Connected On My Linux System?

To determine what PCI devices are connected one of the simplest ways to do this is using the lspci command.

On this page
  1. Introduction
  2. Basic Syntax
  3. Flags
  4. Formatting For Parsing
  5. Conclusion
  6. Additional Links

Have you ever encountered a time when you worked in a remote Linux server and needed to check what was connected to the system’s local PCI Express and PCI buses? To determine what PCI devices are connected one of the simplest ways to do this is using the lspci command.

#Introduction

The lspci command on Linux is a utility that lists the PCI devices connected to a system. The lspci command comes pre-installed on almost all Linux distributions, so you shouldn’t need to worry about installing it. However, if you run into an edge case the package you want to look is pciutils. In this post we will dig into the syntax, what the results mean, and other flags you may find useful.

#Basic Syntax

The simplest syntax of the lspci command is:

Code
lspci

All instances of the command will follow the following syntax:

Code
lspci [options]

Troubleshooting Note: If you receive a permissions denied error when trying to run the lspci command, try again using sudo or a user with elevated privileges.

Results Explained

Let’s break one of these down by section:

00:12.0 Ethernet controller: Red Hat, Inc. Virtio network device

  1. The bus ID
  2. The device class
  3. The Vendor and device information
  4. In some cases a revision number may be included

What Is The Bus ID?

Indicates how the device is connected to the system, this consists of the PCI bus, the slot, and the function. The function is relevant for devices that do more than a single thing for example a dual port Ethernet card.

What Is The Device Class?

The device class indicates the type of device by its function.

What Is The Revision Number?

This indicates the revision or iteration of the device.

#Flags

Below are some of the flags I believe you will find most useful.

The above list is not exhaustive, for a full list check out an online man page or check your local man page by running man lspci.

#Formatting For Parsing

In addition to the above flags if you’re looking to use the output of the lspci command in a script or another pragmatic fashion it is recommended you use one of the sets of flags below:

#Conclusion

In this post we answer the question of how do I list connected PCI devices. The lspci command is the perfect command to answer this question. From basic usage, what the results mean, flags you may find useful, and flags recommend for scripts/programs.

Are you done reading and looking for more, why not check these links out?

Illustrated avatar of CJ Saathoff
Written by

CJ Saathoff

CJ Saathoff writes for the NameHero blog.

More from CJ →