I want to find out what is Linux using to control my hardware. I guess modules and drivers and maybe they are the same.
I got this answer : How do I find out which driver a piece of hardware is using?
And there's a way to list the drivers but I also want to add an identifier to each list item.
If I run this command the this is what happens :
sudo lshw | grep -Eo 'driver=[^ ]+' | sort -u | cut -d\= -f2
agpgart-intel
ahci
ath9k
atl1c
ehci-pci
hub
i915
intel
lpc_ich
mei_me
pcieport
snd_hda_intel
tun
usb-storage
uvcvideo
If you are concerned with only filtering output of lshw
to show device and its corresponding driver, you can use the lshw
and awk
combination bellow:
sudo lshw | awk '/product:/{ if(length(PROD) > 0){PROD=""}; for(i=1;i<=NF;i++) PROD=PROD" "$i } /driver=/{ for(j=1;j<=NF;j++){ if($j~/driver=/) DRIVER=$j };print "---",PROD,DRIVER; PROD=""}'
Basic idea here is that we find lines that have "product: . . . " in them and store into PROD. Because some devices don't list drivers, we could have repeatedly appended line after line to PROD variable, so in the beginning we check length of the PROD string. Another matching that is going on, is for the lines containing the driver=
part. Once we have that, we print both the product and the driver information.
Bellow is the command put together into a script, and sample output:
$ cat ./dev-drivers.sh
#!/bin/bash
sudo lshw | awk '/product:/{ if(length(PROD) > 0){PROD=""};\
for(i=1;i<=NF;i++) PROD=PROD" "$i }\
/driver=/{ for(j=1;j<=NF;j++){ if($j~/driver=/) DRIVER=$j };\
print "---",PROD,DRIVER; PROD=""}'
$ ./dev-drivers.sh
[sudo] password for xieerqi:
--- product: ValleyView SSA-CUnit driver=iosf_mbi_pci
--- product: ValleyView Gen7 driver=i915
--- product: ValleyView 6-Port SATA AHCI Controller driver=ahci
--- product: ValleyView USB xHCI Host Controller driver=xhci_hcd
--- product: ValleyView SEC driver=mei_txe
--- product: ValleyView High Definition Audio Controller driver=snd_hda_intel
--- product: ValleyView PCI Express Root Port driver=pcieport
--- product: RTL8101E/RTL8102E PCI Express Fast Ethernet controller driver=r8169
--- product: ValleyView PCI Express Root Port driver=pcieport
--- product: QCA9565 / AR9565 Wireless Network Adapter driver=ath9k
--- product: ValleyView PCI Express Root Port driver=pcieport
--- product: RTS5229 PCI Express Card Reader driver=rtsx_pci
--- product: ValleyView Power Control Unit driver=lpc_ich
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments