How to Detect the Physical Connected State of a Network Cable/connector?
[[email protected] ~]# for i in $( ls /sys/class/net ); do echo -n $i; ethtool $i | grep Link\ d; done
eth0 Link detected: yes
eth1 Link detected: yes
eth2 Link detected: no
eth3 Link detected: no
lo Link detected: yes
tun0 Link detected: yes
usb0 Link detected: yes
yes: mean cable connected
no: no cable connected