The lspci command is used to display devices and drivers on Linux systems. When you run Linux on a personal computer or server, you sometimes need to identify the hardware in that system. The lspci command is used to display all devices connected to the PCI bus to meet the above

lspci command is used to display devices and drivers on Linux systems.

When you run Linux on a personal computer or server, you sometimes need to identify the hardware in that system. The lspci command is used to display all devices connected to the PCI bus to meet the above requirements. This command is provided by the pciutils package and can be used in a variety of Linux and BSD-based operating systems.

Basic usage

Due to access permissions, the information displayed by ordinary users when running lspci may be limited. Therefore, you can use sudo to run the command, and the system will give a complete infographic.

Running the lspci command directly lists the PCI bus and its connected devices. The following figure is a demo example on my Media Center PC. The picture shows a system based on the AMD Phenom CPU, so it has an AMD chipset, as well as an Atheros wireless adapter and an Nvidia graphics card. All hardware devices list details such as vendor, name and model:

$ sudo lspci00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] RS880 Host Bridge00:02.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780 PCI to PCI bridge (ext gfx port 0)00:04.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to PCI bridge (PCIE port 0)00:05.0 PCI bridge: Advanced Micro Devices, Inc. [AMD] RS780/RS880 PCI to PCI bridge (PCIE port 1)00:11.0 SATA controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 SATA Controller [AHCI mode]00:12.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller00:12.1 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0 USB OHCI1 Controller00:12.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller00:13.0 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI0 Controller00:13.1 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0 USB OHCI1 Controller00:13.2 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB EHCI Controller00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 SMBus Controller (rev 3c)00:14.1 IDE interface: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 IDE Controller00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 LPC host controller00:14.4 PCI bridge: Advanced Micro Devices, Inc. [AMD/ATI] SBx00 PCI to PCI Bridge00:14.5 USB controller: Advanced Micro Devices, Inc. [AMD/ATI] SB7x0/SB8x0/SB9x0 USB OHCI2 Controller00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor HyperTransport Configuration00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Address Map00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Address Map00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor DRAM Controller00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Miscellaneous Control00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Family 10h Processor Link Control01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GTX 650] (rev a1)01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1)02:00.0 Network controller: Qualcomm Atheros AR9287 Wireless Network Adapter (PCI-Express) (rev 01)

Detailed output

Adding the -v option will display the detailed information of each device. You can use -vv or -vvv to get more device details. At the -v level, lspci displays various subsystem and memory addresses, interrupt request (IRQ) numbers and some other functional information for all devices. The output information will be very long. Try it on your system.

Use grep to filter search

You may need to narrow the search range. For example, the RPM Fusion website has instructions for installing the Nvidia graphics driver, which first uses the grep command to locate graphics card information.Here is the output I got on my laptop:

$ sudo lspci | grep -e VGA00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)$ sudo lspci | grep -e 3D01:00.0 3D controller: NVIDIA Corporation GM108M [GeForce MX130] (rev a2)

(LCTT translation note: The original text is "above", should be the author's typo) grep command located a VGA device on my media center PC, but it did not show 3D equipment.

$ sudo lspci | grep -e VGA01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GTX 650] (rev a1)$ sudo lspci | grep -e 3D$

Search

by vendor ID There is another way to use it without grep. Suppose I want to confirm if this computer has other Nvidia devices, before that we need some additional information, the vendor and device ID numbers displayed using the -nn option. On my Media Center PC, this option gives my VGA card, vendor ID, and device ID:

$ sudo lspci -nn | grep -e VGA01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107 [GeForce GTX 650] [10de:0fc6] (rev a1) 

There are colon-separated numbers in square brackets after the device name, namely vendor and device ID. The output indicates that the supplier ID of the equipment manufactured by Nvidia Corporation is 10de. The

-d option is used to specify all devices of the vendor, device, or class ID. Here are all Nvidia devices in my system (keep -nn to parse vendor ID):

$ sudo lspci -nn -d 10de:01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107 [GeForce GTX 650] [10de:0fc6] (rev a1)01:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio Controller [10de:0e1b] (rev a1)

From the output, I have an Nvidia audio device in addition to the graphics card. They all actually belong to the same Nvidia GeForce GTX 650 card, but this is still a good example.

kernel module

combined with PCI hardware devices, lspci can use the -k option to display which driver modules are loaded by the kernel. I added this option to my lspci command to view information about my Nvidia device.

$ sudo lspci -nn -k -d 10de:01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK107 [GeForce GTX 650] [10de:0fc6] (rev a1) Subsystem: eVga.com. Corp. GK107 [GeForce GTX 650] [3842:2650] Kernel driver in use: nvidia Kernel modules: nvidiafb, nouveau, nvidia_drm, nvidia01:00.1 Audio device [0403]: NVIDIA Corporation GK107 HDMI Audio Controller [10de:0e1b] (rev a1) Subsystem: eVga.com. Corp. GK107 HDMI Audio Controller [3842:2650] Kernel driver in use: snd_hda_intel Kernel modules: snd_hda_intel

You can see two additional lines are displayed: the kernel driver in use Kernel driver in use and Kernel modules, which lists the modules that can be used to support the device.

synchronizes the latest status

New devices and suppliers are always iterating. If you see a device that appears as unknown, it means that your PCI device ID database may be outdated. There are two ways to check for updates. The -Q option will use DNS to query the central database, of course, this requires networking.

$ sudo lspci -Q

You can also update the local PCI ID database by running the command update-pciids.

$ sudo update-pciidsDownloaded daily snapshot dated 2021-08-22 03:15:01

Learn more about your hardware

Of course, lspci is just one of the many commands in Linux used to query system hardware and software. Readers can learn more about Linux hardware by reading articles about USB devices: Use this USB ID repository to identify more devices on Linux.

via: https://opensource.com/article/21/9/lspci-linux-hardware

Author: Alan Formy-Duval Topic: lujun9972 Translator: unigeorge Proofreading: turbokernel

This article was originally compiled by LCTT, and Linux China Honors launched