Skip to content

Instantly share code, notes, and snippets.

@LeSpocky
Forked from JonathonReinhart/sample_output
Last active June 25, 2020 08:08
Show Gist options
  • Save LeSpocky/ea9f441027d6de6640b73a631bedf25a to your computer and use it in GitHub Desktop.
Save LeSpocky/ea9f441027d6de6640b73a631bedf25a to your computer and use it in GitHub Desktop.
Show Ethernet drivers on Linux
% what_eth_drivers.sh
br0 [ac:22:0b:c3:cd:2a]: (up)
docker0 [02:42:6b:bb:b4:67]: (down)
enp3s0 [ac:22:0b:c3:cd:2a]: r8169 (up)
enp5s0 [00:01:02:d8:91:07]: 3c59x (unknown)
enx00e04c6800e5 [00:e0:4c:68:00:e5]: r8152 (down)
lo [00:00:00:00:00:00]: (unknown)
vmnet1 [00:50:56:c0:00:01]: (unknown)
vmnet8 [00:50:56:c0:00:08]: (unknown)
#!/bin/bash
#
# See: https://unix.stackexchange.com/a/225496/50007
# See: https://gist.github.com/JonathonReinhart/573694d541dc2108f7629aaa615cef3b
#
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 "%16s [%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