Linux lspci Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux lspci command, which is a powerful tool used to display information about the Peripheral Component Interconnect (PCI) buses and devices connected to the system. The lab will cover the purpose of the lspci command, its various options and flags, and how to identify the PCI devices on the system. This information can be useful for troubleshooting hardware issues, identifying the components of the system, and understanding the overall hardware configuration.

The lab will start by running the basic lspci command to display the PCI devices detected on the system, including their device names, vendor information, and other relevant details. We will then explore the different options and flags available with the lspci command to obtain more specific information about the PCI devices.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/TextProcessingGroup(["`Text Processing`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux/BasicSystemCommandsGroup -.-> linux/man("`Manual Access`") linux/TextProcessingGroup -.-> linux/grep("`Pattern Searching`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") subgraph Lab Skills linux/man -.-> lab-422782{{"`Linux lspci Command with Practical Examples`"}} linux/grep -.-> lab-422782{{"`Linux lspci Command with Practical Examples`"}} linux/sudo -.-> lab-422782{{"`Linux lspci Command with Practical Examples`"}} end

Understand the Purpose of lspci Command

In this step, we will explore the purpose of the lspci command in Linux. The lspci command is a powerful tool used to display information about the Peripheral Component Interconnect (PCI) buses and devices connected to the system.

The lspci command provides detailed information about the PCI devices installed on your system, including their device names, vendor information, and other relevant details. This information can be useful for troubleshooting hardware issues, identifying the components of your system, and understanding the overall hardware configuration.

Let's start by running the basic lspci command:

sudo lspci

Example output:

00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (rev 07)
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (rev 02)
00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller (rev 10)
00:14.2 RAM memory: Intel Corporation Cannon Lake PCH Shared SRAM (rev 10)
00:16.0 Communication controller: Intel Corporation Cannon Lake PCH HECI Controller (rev 10)
00:17.0 SATA controller: Intel Corporation Cannon Lake PCH SATA AHCI Controller (rev 10)
00:1b.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #21 (rev f0)
00:1c.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #1 (rev f0)
00:1d.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #13 (rev f0)

This output shows the various PCI devices detected on the system, including the host bridge, PCI bridges, VGA controller, USB controller, and more. Each line represents a PCI device, with information about its device ID, vendor, and other details.

The lspci command can also be used with various options and flags to display more specific information about the PCI devices. We will explore these in the next step.

Explore lspci Command Options and Flags

In this step, we will explore the various options and flags available with the lspci command to retrieve more detailed information about the PCI devices on your system.

Let's start by checking the available options for the lspci command:

man lspci

This will display the manual page for the lspci command, which lists all the available options and their descriptions.

Some commonly used lspci options include:

  • -v: Display verbose output, providing more detailed information about each PCI device.
  • -vv: Display very verbose output, including additional technical details.
  • -s <slot>: Display information only for the PCI device at the specified slot.
  • -d <vendor>:<device>: Display information only for devices from the specified vendor and/or device ID.
  • -n: Display the device and vendor IDs in numeric format instead of looking up the names.
  • -nn: Display the device and vendor IDs in numeric format and also include the name lookups.

Let's try some of these options:

sudo lspci -v

Example output:

00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
    Subsystem: Lenovo 8th Gen Core Processor Host Bridge/DRAM Registers
    Flags: bus master, fast devsel, latency 0
    Capabilities: <access denied>
    Kernel driver in use: skl_uncore

00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (rev 07)
    Flags: bus master, fast devsel, latency 0, IRQ 122
    Bus: primary=00, secondary=01, subordinate=01, sec-latency=0
    I/O behind bridge: 0000c000-0000cfff
    Memory behind bridge: f6000000-f60fffff
    Prefetchable memory behind bridge: 00000000e0000000-00000000e01fffff
    Capabilities: <access denied>
    Kernel driver in use: pcieport

The -v option provides more detailed information about each PCI device, including the device name, vendor, capabilities, and the kernel driver in use.

You can also combine options to get even more specific information:

sudo lspci -nn

This will display the PCI device and vendor IDs in numeric format, along with the name lookups.

sudo lspci -s 00:02.0 -v

This will show the detailed information for the PCI device at slot 00:02.0.

Explore the different lspci options and flags to understand how you can retrieve the specific information you need about the PCI devices on your system.

Identify PCI Devices on the System

In this final step, we will learn how to use the lspci command to identify the PCI devices on your system and understand the information provided.

Let's start by running the basic lspci command again:

sudo lspci

Example output:

00:00.0 Host bridge: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers (rev 07)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller (rev 07)
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 630 (rev 02)
00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller (rev 10)
00:14.2 RAM memory: Intel Corporation Cannon Lake PCH Shared SRAM (rev 10)
00:16.0 Communication controller: Intel Corporation Cannon Lake PCH HECI Controller (rev 10)
00:17.0 SATA controller: Intel Corporation Cannon Lake PCH SATA AHCI Controller (rev 10)
00:1b.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #21 (rev f0)
00:1c.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #1 (rev f0)
00:1d.0 PCI bridge: Intel Corporation Cannon Lake PCH PCI Express Root Port #13 (rev f0)

This output shows the various PCI devices detected on the system, including the host bridge, PCI bridges, VGA controller, USB controller, and more. Each line represents a PCI device, with information about its device ID, vendor, and other details.

To get more detailed information about a specific PCI device, you can use the lspci -v command:

sudo lspci -v -s 00:02.0

This will display the detailed information for the PCI device at slot 00:02.0, which in this case is the VGA controller.

You can also use the lspci -nn command to see the numeric device and vendor IDs, which can be useful for identifying specific devices:

sudo lspci -nn

Example output:

00:00.0 Host bridge [0600]: Intel Corporation 8th Gen Core Processor Host Bridge/DRAM Registers [8086:3e30] (rev 07)
00:01.0 PCI bridge [0604]: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor PCIe Controller [8086:1901] (rev 07)
00:02.0 VGA compatible controller [0300]: Intel Corporation UHD Graphics 630 [8086:3e9b] (rev 02)
00:14.0 USB controller [0c03]: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller [8086:a36d] (rev 10)
00:14.2 RAM memory [0500]: Intel Corporation Cannon Lake PCH Shared SRAM [8086:a36f] (rev 10)
00:16.0 Communication controller [0780]: Intel Corporation Cannon Lake PCH HECI Controller [8086:a360] (rev 10)
00:17.0 SATA controller [0106]: Intel Corporation Cannon Lake PCH SATA AHCI Controller [8086:a353] (rev 10)
00:1b.0 PCI bridge [0604]: Intel Corporation Cannon Lake PCH PCI Express Root Port #21 [8086:a344] (rev f0)
00:1c.0 PCI bridge [0604]: Intel Corporation Cannon Lake PCH PCI Express Root Port #1 [8086:a338] (rev f0)
00:1d.0 PCI bridge [0604]: Intel Corporation Cannon Lake PCH PCI Express Root Port #13 [8086:a33c] (rev f0)

This output shows the PCI device IDs in numeric format, which can be useful for identifying specific devices or looking up their specifications.

By using the lspci command with various options, you can gather detailed information about the PCI devices on your system, which can be valuable for troubleshooting, hardware identification, and understanding the overall system configuration.

Summary

In this lab, we explored the purpose and usage of the lspci command in Linux. The lspci command is a powerful tool that provides detailed information about the Peripheral Component Interconnect (PCI) buses and devices connected to the system. We learned how to use the basic lspci command to display the PCI devices installed on the system, including their device names, vendor information, and other relevant details. This information can be useful for troubleshooting hardware issues, identifying the components of the system, and understanding the overall hardware configuration. We also discussed how the lspci command can be used with various options and flags to display more specific information about the PCI devices.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like