In a Linux environment, I need to detect the physical connected or disconnected state of an RJ45 connector to its socket. Preferably using BASH scripting only.
The
You can use ifconfig.
# ifconfig eth0 up # ifconfig eth0
If the entry shows RUNNING, the interface is physically connected. This will be shown regardless if the interface is configured.
This is just another way to get the information in /sys/class/net/eth0/operstate.
/sys/class/net/eth0/operstate