6 practical uses for the lspci command on Linux

Are you experiencing hardware issues on your Linux device? Or maybe you’re just curious about what information you can gather using terminal commands? You should try these lspci command examples.
The lspci command line application gives you information about PCI (Peripheral Component Interconnect) bus systems and devices connected to your PC’s motherboard. This includes devices such as your GPU, your Ethernet port, and your Wi-Fi card. If you’re familiar with the ls command, then you can understand the command’s name: “list PCI”. Information about your device’s internal systems is a few keystrokes away with lspci.
Check all PCI devices
The most basic use-case for lspci is getting a printout of all PCI devices connected to your system. You can just run lspci by itself to get a brief overview.
You’ll see every entry appear first with the slot address, a set of numbers and sometimes letters unique to the device. There’s also a class listed, the vendor name, and the device name. You may also see subsystem vendor and device names when subsystems exist. You might see a revision number (like “rev 04”) and an associated programming language at the end too.
Keep in mind that the devices listed here are PCI devices. While that includes USB controllers, it does not include USB-connected peripherals. If you want to see what USB devices are plugged into those controllers, then you want the lsusb command.
Similarly, if you’re trying to work directly with your connected storage devices, then you should look into the lsblk command.
Search for specific devices
OK, lspci’s output can be a little overwhelming to eyeball when you’re trying to identify something specific. With an assist from the tried and true grep command, you can look for specific devices by search term.
For example, let’s say you want to see all USB controllers. Just run this command:
lspci | grep "USB"
This will filter out all results that don’t mention USB in the basic info.
Search terms can be tricky though. For example, your graphics card may or may not mention the word “graphics” or “GPU” anywhere in its device name. However, I know that the integrated GPU in use on my laptop has the word Iris in its name, so I can run this command:
lspci | grep "Iris"
As you can see, I successfully found the iGPU on my laptop. It might take some trial and error to filter correctly on your Linux system. Try different terms that you know may be associated with your device.
How to List Your Computer’s Devices From the Linux Terminal
Easier than ripping it apart.
Get detailed info about devices
Let’s say you’ve identified an important device. You could use other commands to get further info, but lspci is capable of telling you quite a bit about them itself if you use the verbose option. This can be useful especially when someone is helping you troubleshoot your Linux system, a case where knowing as much as possible about the devices in play is always helpful.
To get a detailed reading of all devices, run lspci with the -v flag, short for “verbose”:
lspci -v
Some info requires root to be viewable, so you might want to try sudo lspci -v if you have permission. Otherwise you’ll see access denied in certain readouts.
The lspci command actually has two more levels of verbosity you can access by typing -vv or -vvv. You’ll end up with a ton of text to parse, though. Unless you’re a developer, you probably won’t gain anything useful with those printouts.
If you want to know how the devices in lspci‘s output are related to each other, you can run the -t option to get everything organized into a “tree.” By default, it will only show you device slots, but if you increase verbosity, you can see names too.
lspci -tv
See which driver your device is using
Sometimes it’s useful to know which driver your PCI device is using. Graphics drivers in particular are a subject of a lot of discussion in the Linux world because the one you have installed sometimes isn’t the best one available.
Fortunately, the driver being used by your GPU, or any other device, is included in lspci‘s output. even without root. For example, we already identified the iGPU on my laptop earlier at address 00:02.0. I can check which driver it’s using by running this command:
lspci -ks 00:02.0
The -k flag gets us kernel information while, again, the -s flag tells lspci you want just the specific device located at the slot that follows.
11 Overlooked Linux Commands You Really Should Be Using
These commands could significantly enhance your workflow!
Get unique device codes
Sometimes you need to find more information about specific devices. lspci is able to give you unique vendor and device codes—more unique than just the device name—that you can then look up online or give to the vendor when you need specialized assistance with it.
All you need to do is use the -nn flag, which gets you vendor and device names and codes. For example, I can get that info for my iGPU with this command:
lspci -nns 00:02.0
You can see the output I get shows a set of codes at the end: 8086:a7a0. 8086 is Intel’s vendor code, and a7a0 is the unique code for the integrated graphics device installed in my PC. If you do a web search for those codes, you’ll find detailed info about it.
There are a lot of commands for the Linux terminal that are surprisingly useful. The traceroute command may help you troubleshoot your internet connection, and mastering the systemctl command will help you better manage the services running on your device.



