Continuing with a theme, this article will explain how to use the terminal to view what’s attached via PCI (Peripheral Component Interconnect) to your computer. PCI devices are the ones in the add-on slots in your computer. They’re typically internal devices, though you can get USB powered external devices with PCI-e slots, they kind of defeat the purpose. For this article, we’ll be using lscpi.
You may also be interested in reading up about lshw and lscpu. I didn’t intend for this to be a ‘series’ but that’s what it’s starting to look like. That’s nice, however. They’re small bites that let you sample the buffet that is the Linux terminal.
This one is just a little more complicated than the last. For starters, you may not have lscpi immediately available. You may have it installed by default, but you might not. It really depends on your distro. Either way, it’s in your default repositories.
If you don’t have it installed, it’s in the package ‘pciutils’. So, use your package manager to install it. For example, with apt you’d do this:
Once you have it installed, you’ll see the manual defines ‘lspci’ as:
lspci – list all PCI devices
If you don’t know, PCI devices are a class of devices that are add-ons to your motherboard. They’re mostly the devices that go in the slots, such as graphics cards or sound cards. They can be used for all sorts of things, these days even being used for M.2 devices that hold SSD drives for rapid storage. They’re great because they have a fast bus speed, meaning that your computer can interact with them faster because data moves faster in both directions than it does for, for example, a USB device.
Except PCI devices aren’t just limited to the things that go in slots. Your motherboard probably uses that same spec to interact with other devices. For example, your Ethernet and sound card may be listed – even though they’re ‘on-board’ and not actually add-on cards. That’s your motherboard using the same sort of bus spec but not actually using a physical port. Additionally, there are different types of PCI specifications, but we don’t need to get into that today.
And, well, once again the ‘lspci’ name tells you what it does, now that you know that’s what it does. It lists PCI devices, just as the name implies. There are a couple of ways that you’d realistically want to use it.
NOTE: The results from ‘lspci’ are drawn from the The PCI ID Repository and may actually not be accurate. Yup. You could get inaccurate results from this command, but we throw it around daily as though it’s infallible. And now you know…
Where were we? Oh, yeah… We were going to use ‘lscpi’ for something useful. So, let’s crack open that terminal by using your keyboard to press
That will list all your PCI devices in a quick and easy to read list. You may also want to get the verbose output and that’s done like:
The output of that command should be fairly obvious. After all, it does what it says it does on the tin. That’s also perhaps the more useful of the commands. It’s definitely the one that I use most frequently.
If you take the numbers from the start of each line from the output of the above command and use the -t switch you’ll actually get an understandable ‘tree’ output that will help you further understand what’s going on inside your case without opening it up. If one PCI device has multiple entries (as many do) it’ll make that easier to understand. It’s simply:
However you can easily put the two of those together and simply get a great verbose tree output with:
That’s plenty easy to understand but some folks may find it a bit overwhelming. I don’t usually need that much information, so I tend to run the command without any switches. As I bounce between devices, it’s enough to just check and make sure I know what I’m working with.
NOTE: Older versions required -vvv for verbose and -tree were needed to perform those operations. The current versions simply use the -v and -t switches.
And there you have it. Yet another way to view hardware information from within the terminal. You may have noticed a trend and probably can narrow down your guess as to what the next article is gonna be about! If lscpi’s parent package is not installed, it’s really easy to get and you can then run the command. If you don’t have access to many tools, you almost certainly have access to this one.
Like always, thanks for reading. Be sure to sign up for the newsletter. I’ll only send you site-related material and won’t sell your email address to anyone. I promise, I won’t ever send you any spam – just site stuff!
for refined output you can pipe lspci through grep; for instance on my laptop :
bash-5.0# lspci -k | grep -iA3 vga
00:01.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Stoney [Radeon R2/R3/R4/R5 Graphics] (rev e2)
Subsystem: Hewlett-Packard Company Stoney [Radeon R2/R3/R4/R5 Graphics]
Kernel driver in use: amdgpu
Kernel modules: amdgpu