Using the lspci command (with examples)

Using the lspci command (with examples)

The lspci command is a Linux utility that lists all the PCI devices present in your system. It provides detailed information about each device such as the vendor, device ID, driver used, and more. By using various command-line options, you can customize the output to display the specific information you require. In this article, we will explore several use cases of the lspci command along with code examples and their output.

Use case 1: Show a brief list of devices

lspci

Motivation: Sometimes, you just need a quick overview of all the PCI devices connected to your system. This command provides a concise list that includes the vendor name and device ID of each device.

Example output:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/i3/i5/i7 DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
...

Use case 2: Display additional info

lspci -v

Motivation: If you require more detailed information about each device, this command provides additional details such as IRQ, I/O ports, and memory regions. This can be useful for troubleshooting or extracting specific device information.

Example output:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/i3/i5/i7 DRAM Controller (rev 09)
    Subsystem: ASRock Incorporation Device 6a55
    Flags: bus master, fast devsel, latency 0
    Capabilities: [e0] Vendor Specific Information: Len=0c <?>
...

Use case 3: Display drivers and modules handling each device

lspci -k

Motivation: If you want to identify the drivers and modules associated with each device, this command provides the necessary information. It helps you determine if the correct drivers are loaded for each device and can aid in troubleshooting device-related issues.

Example output:

00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v2/i3/i5/i7 DRAM Controller (rev 09)
    Subsystem: ASRock Incorporation Device 6a55
    Kernel driver in use: ivb_uncore
    Kernel modules: ie31200_edac
...

Use case 4: Show a specific device

lspci -s 00:18.3

Motivation: If you are only interested in a particular device, you can use the -s flag followed by the device’s PCI address. This command allows you to quickly retrieve details about a specific device without having to scroll through the entire list of devices.

Example output:

00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Device 15b3 (rev 01)
    Subsystem: Gigabyte Technology Co., Ltd Device 5001
    Flags: bus master, fast devsel, latency 0
    Capabilities: [f0] Secure device <?>
...

Use case 5: Dump info in a readable form

lspci -vm

Motivation: If you prefer a more readable and structured output, this command is useful. It formats the information in a way that is easier to parse and understand, especially when dealing with complex PCI devices that have multiple capabilities or features.

Example output:

Slot: 00:00.0
Class: 0600 Host bridge
Vendor: Intel Corporation
Device: Xeon E3-1200 v2/i3/i5/i7 DRAM Controller
SVendor: ASRock Incorporation
SDevice: Device 6a55
...

In conclusion, the lspci command is a powerful tool for examining the PCI devices in your Linux system. Whether you need a brief overview, detailed information, or specific device details, lspci provides the necessary flexibility to extract the desired information.

Related Posts

How to use the command "wat2wasm" (with examples)

How to use the command "wat2wasm" (with examples)

The “wat2wasm” command is used to convert a file from the WebAssembly text format to the binary format.

Read More
How to use the command 'docker ps' (with examples)

How to use the command 'docker ps' (with examples)

The docker ps command is used to list Docker containers. It provides information about the running and stopped containers, including their status, names, and IDs.

Read More
How to use the command 'carbon-now' (with examples)

How to use the command 'carbon-now' (with examples)

The ‘carbon-now’ command is a tool that allows you to create beautiful images of your code.

Read More