lspci ‐ #system #networking - five4nets/Linux-Knowledgebase GitHub Wiki
lspci
Command in Linux
Tutorial: Using the The lspci
command in Linux is a powerful utility for displaying information about PCI (Peripheral Component Interconnect) buses and devices connected to them, such as graphics cards, network adapters, and USB controllers. This tutorial explains the lspci
command, its options, and provides multiple examples to help you understand and use it effectively.
lspci
?
What is lspci
is a command-line tool that lists all PCI devices in a Linux system. It retrieves details from the PCI bus and presents information like device IDs, vendor names, and device classes. It is commonly used for hardware troubleshooting, system inventory, and driver configuration.
Prerequisites
- A Linux system with
lspci
installed (usually part of thepciutils
package). - Basic familiarity with the Linux terminal.
- Root privileges may be required for some options (use
sudo
).
To check if lspci
is installed, run:
lspci --version
If not installed, install it using your package manager, e.g.:
- On Debian/Ubuntu:
sudo apt install pciutils
- On Fedora:
sudo dnf install pciutils
- On Arch Linux:
sudo pacman -S pciutils
Basic Syntax
lspci [options]
Without options, lspci
lists all PCI devices with basic information.
Common Options
Here are frequently used lspci
options with explanations:
-v
: Verbose mode, shows detailed information about each device.-vv
: Very verbose mode, provides even more details (useful for debugging).-n
: Numeric output, displays vendor and device IDs as numbers instead of names.-nn
: Shows both numeric IDs and names.-k
: Displays kernel drivers and modules used by each device (requires root).-t
: Displays a tree-like hierarchy of PCI buses and devices.-d [vendor]:[device]
: Filters output to show only devices matching the specified vendor and device IDs.-m
: Machine-readable output, useful for scripting.-s [[[domain]:]bus]:][slot][.[func](/five4nets/Linux-Knowledgebase/wiki/[[domain]:]bus]:][slot][.[func)
: Filters devices by their PCI address (domain, bus, slot, or function).
For a full list of options, run:
man lspci
Examples
1. List All PCI Devices
To display a basic list of all PCI devices:
lspci
Sample Output:
00:00.0 Host bridge: Intel Corporation 12th Gen Core Processor Host Bridge/DRAM Registers (rev 02)
00:01.0 PCI bridge: Intel Corporation 12th Gen Core Processor PCI Express Root Port (rev 02)
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3060] (rev a1)
This shows the PCI address, device class, vendor, and device name.
2. Display Detailed Information
Use the -v
or -vv
option for more details:
lspci -v
Sample Output (partial):
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3060] (rev a1)
Subsystem: ASUSTeK Computer Inc. Device 8816
Flags: bus master, fast devsel, latency 0, IRQ 128
Memory at fc000000 (32-bit, non-prefetchable) [size=16M]
Capabilities: <access denied>
For even more details, use:
sudo lspci -vv
Note: sudo
is needed for some fields like capabilities due to permission restrictions.
3. Show Numeric IDs
To display vendor and device IDs numerically (useful when names aren’t resolved):
lspci -n
Sample Output:
00:00.0 0600: 8086:4640 (rev 02)
01:00.0 0300: 10de:2503 (rev a1)
Here, 8086
is Intel’s vendor ID, and 4640
is the device ID.
To show both IDs and names:
lspci -nn
Sample Output:
00:00.0 Host bridge [0600]: Intel Corporation 12th Gen Core Processor Host Bridge/DRAM Registers [8086:4640] (rev 02)
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA104 [GeForce RTX 3060] [10de:2503] (rev a1)
4. Display Kernel Drivers
To see which kernel drivers are in use (requires root):
sudo lspci -k
Sample Output (partial):
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3060] (rev a1)
Subsystem: ASUSTeK Computer Inc. Device 8816
Kernel driver in use: nvidia
Kernel modules: nvidia
This shows the nvidia
driver is handling the GPU.
5. Display PCI Hierarchy
To visualize the PCI bus structure as a tree:
lspci -t
Sample Output:
-[0000:00]-+-00.0 Intel Corporation 12th Gen Core Processor Host Bridge/DRAM Registers
+-01.0-[01]----00.0 NVIDIA Corporation GA104 [GeForce RTX 3060]
+-02.0 Intel Corporation Alder Lake-P Integrated Graphics Controller
...
This is useful for understanding how devices are connected to buses.
5. Filter by Vendor and Device ID
To show only devices from a specific vendor and device (e.g., NVIDIA’s vendor ID 10de
):
lspci -d 10de:
Sample Output:
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3060] (rev a1)
01:00.1 Audio device: NVIDIA Corporation GA104 High Definition Audio Controller (rev a1)
6. Filter by PCI Address
To display a specific device by its PCI address (e.g., bus 01, slot 00, function 0):
lspci -s 01:00.0
Sample Output:
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3060] (rev a1)
7. Machine-Readable Output
For scripting, use the -m
option:
lspci -m
Sample Output:
00:00.0 "Host bridge" "Intel Corporation" "12th Gen Core Processor Host Bridge/DRAM Registers" -r02 ...
01:00.0 "VGA compatible controller" "NVIDIA Corporation" "GA104 [GeForce RTX 3060]" -ra1 ...
This format is easier to parse programmatically.
Practical Use Cases
- Identify Hardware for Driver Installation: Use
lspci -nn
to find vendor and device IDs, then search for appropriate drivers. - Troubleshoot Hardware Issues: Check if devices are detected correctly with
lspci -v
or verify drivers withlspci -k
. - System Inventory: Use
lspci -m
to generate a machine-readable list of hardware for documentation. - Debug PCI Bus Conflicts: Use
lspci -t
to inspect the bus hierarchy.
Tips
- Combine options for specific needs, e.g.,
lspci -v -s 01:00.0
for verbose output of a single device. - If
lspci
doesn’t show expected devices, ensure the hardware is properly connected and powered. - Use
sudo
for options requiring root access to avoid partial output. - Cross-reference vendor/device IDs with the PCI ID database (see references).
References
- PCI ID Repository - Look up vendor and device IDs.
- Linux man page for lspci - Official documentation.
- Arch Linux Wiki: PCI Passthrough - Advanced use case with
lspci
. - Ubuntu Documentation: Hardware Troubleshooting - General hardware diagnostics with
lspci
.
Conclusion
The lspci
command is an essential tool for inspecting PCI devices in Linux. By mastering its options and combining them effectively, you can diagnose hardware issues, manage drivers, and document your system’s hardware configuration. Experiment with the examples above to become comfortable with lspci
’s capabilities.