Show Ethernet drivers on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ~/what_eth_drivers.sh | |
eth0 [52:54:00:aa:bb:cc]: virtio_net (up) | |
eth1 [52:54:00:dd:ee:ff]: virtio_net (up) | |
eth2 [52:54:00:99:88:77]: virtio_net (up) | |
lo [00:00:00:00:00:00]: (unknown) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for f in /sys/class/net/*; do | |
dev=$(basename $f) | |
driver=$(readlink $f/device/driver/module) | |
if [ $driver ]; then | |
driver=$(basename $driver) | |
fi | |
addr=$(cat $f/address) | |
operstate=$(cat $f/operstate) | |
printf "%10s [%s]: %10s (%s)\n" "$dev" "$addr" "$driver" "$operstate" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this nice script. Side note: here I have fixed the warnings that😉
shellcheck
would print.(Basically variables should be double-quoted to prevent globbing and word splitting.)