Today's article is another 'back to basics' kinda article...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,549
Reaction score
7,304
Credits
69,523
Today, we're just going to be covering the 'lspci' command. There's quite a bit to it, as compared to some others. However, the ways you're most likely to use the command are covered, just like the other articles of this nature.


Yes, they're interspersed with other articles. That just seemed like the best idea. I do love me some feedback.
 


osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
541
Reaction score
450
Credits
4,997
Hello KGIII. I'm writing to report some differences between the outputs of the commands in the article and those on this debian (bookworm) system:
Code:
[[email protected] ~]$ lspci |grep Network    <<- no output.

[[email protected] ~]$ lspci |grep VGA
01:00.0 VGA compatible controller: NVIDIA Corporation GT218 [GeForce 210] (rev a2)

[[email protected] ~]$ lspci -class display    <<- outputs "invalid option" message.
lspci: invalid option -- 'c'
Usage: lspci [<switches>]
Basic display modes:
-mm             Produce machine-readable output (single -m for an obsolete format)
-t              Show bus tree
<snip>

[[email protected] ~]$ lspci -class network   <<- outputs "invalid option" message.
lspci: invalid option -- 'c
<snip>

[[email protected] ~]$ lspci -class memory     <<- outputs "invalid option" message.
lspci: invalid option -- 'c'
<snip>

In the manpage there is an option for the use of the "class" variable in relation to output info on devices thus:
Code:
lspci -d [<vendor>]:[<device>][:<class>[:<prog-if>]]
but on my system one doesn't use the term "class" in any form that I can find. To get the info one needs to know the class ID, and for that the manpage refers the reader to the file: /usr/share/misc/pci.ids, where one discovers that the class ID for the Network controller is: 02, and the subclass ID of ethernet is: 00, so the
command for info is as follows:
Code:
[[email protected] ~]$ lspci -d ::0200
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
or one can use the variant: lspci -d *:*:200, to get the same result where * means any vendor and any device. More info is available from a command such as:
Code:
[[email protected] ~]$ lspci -nnkd ::200
02:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)
        Subsystem: Gigabyte Technology Co., Ltd Onboard Ethernet [1458:e000]
        Kernel driver in use: r8169
        Kernel modules: r8169
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
        Subsystem: TP-LINK Technologies Co., Ltd. TG-3468 Gigabit PCI Express Network Adapter [7470:3468]
        Kernel driver in use: r8169
        Kernel modules: r8169

A different approach is to use grep to select info which is included on nearby lines from lspci output. The following gather relevant info for the graphics card and ethernet:
Code:
[[email protected] ~]$ lspci -nnk | grep -i -A 3 vga
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GT218 [GeForce 210] [10de:0a65] (rev a2)
        Subsystem: ASUSTeK Computer Inc. GT218 [GeForce 210] [1043:8354]
        Kernel driver in use: nouveau
        Kernel modules: nouveau


[[email protected] ~]$ lspci -nnk | grep -i -A 3 network
        Subsystem: TP-LINK Technologies Co., Ltd. TG-3468 Gigabit PCI Express Network Adapter [7470:3468]
        Kernel driver in use: r8169
        Kernel modules: r8169

[[email protected] ~]$ lspci -nnk | grep -i -A 3 eth
02:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)
        Subsystem: Gigabyte Technology Co., Ltd Onboard Ethernet [1458:e000]
        Kernel driver in use: r8169
        Kernel modules: r8169
04:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 06)
        Subsystem: TP-LINK Technologies Co., Ltd. TG-3468 Gigabit PCI Express Network Adapter [7470:3468]
        Kernel driver in use: r8169
        Kernel modules: r8169

I'd be interested to know which version of lspci was used for the article. The following output shows from where the one used for the above commands came:
Code:
[[email protected] ~]$ apt policy pciutils
pciutils:
  Installed: 1:3.9.0-2
  Candidate: 1:3.9.0-2
  Version table:
 *** 1:3.9.0-2 500
        500 http://ftp.au.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status
Using sudo made no difference to the above outputs.
 
Last edited:
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,549
Reaction score
7,304
Credits
69,523
Using sudo made no difference to the above outputs.

Weird... I dunno what to think, at this point - and I just watched the Niners win a playoff game (which means I'm not gonna be all that helpful tonight).

Code:
[email protected]:~$ apt policy pciutils
pciutils:
  Installed: 1:3.6.4-1ubuntu0.20.04.1
  Candidate: 1:3.6.4-1ubuntu0.20.04.1
  Version table:
 *** 1:3.6.4-1ubuntu0.20.04.1 500
        500 http://ubuntu.mirrors.pair.com/archive focal-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     1:3.6.4-1 500
        500 http://ubuntu.mirrors.pair.com/archive focal/main amd64 Packages

Now that I look at it, I think I may have ended up taking my notes from *lshw* in the middle of it. That seems to be what I did. I'd have to go to the computer - but I bet I somehow started typing in lshw commands or mixing the notes up for the two of them. That one was written straight from my notes I think - which are usually pretty solid.

Alas, I wrote it days ago in prep for my busy days.

I'll have to tear into it and fix it tomorrow. Thanks for bringing it to my attention.
 

osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
541
Reaction score
450
Credits
4,997
This command in the amended page doesn't output anything here, as mentoned in post #2:
Code:
[[email protected] ~]$ lspci | grep Network
lspci appears to be more interested in devices, so it produces output with:
Code:
[[email protected] ~]$ lspci | grep -i eth
02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0c)
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 06)
lspci is quite happy to provide a lot of info without sudo, unlike lshw.
 
Last edited:
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,549
Reaction score
7,304
Credits
69,523
lspci appears to be more interested in devices, so it produces output with:

Yeah, I made a quick edit today to get rid of a chunk of stuff. I'm horribly occupied today and will be for the next few hours and then for another hour or so after that. (Mecum auction. I made some very costly decisions.)
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,549
Reaction score
7,304
Credits
69,523
Also, and yeah, I was able to go back through the terminal history in a VM where I was poking while writing the article. For some reason, I switched to LSHW for like half the commands and conflated it with the other half.

That doesn't normally happen, but after 300+ articles I'm bound to make a mistake eventually!
 

osprey

Well-Known Member
Joined
Apr 15, 2022
Messages
541
Reaction score
450
Credits
4,997
I'm reminded of the Robin Sharma aphorism: "There are no mistakes in life, only lessons". It gets me by most of the time :)
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
8,549
Reaction score
7,304
Credits
69,523
LOL Even the pros throw an interception now and again.

I've been pretty distracted since like January 4th. It's the largest/longest Mecum auction.

It's over now. Finally...
 
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online


Latest posts

Top