How to find out the connected state of a network cable in Linux

You may also like...

  • helloworld

    ip a
    eth0: mtu 1500 qdisc mq state UP group default qlen 1000
    eth1: mtu 1500 qdisc noop state DOWN group default qlen 1000

  • TheRealTachyon

    Since not everyone has yet been plagued with yet another ridiculous systemd related change in long standing conventions, you should mention that the odd looking network device names in your examples are only for Linux distributions that have migrated to systemd’s “Predictable Network Interface naming” standard which throws out the “eth0” and “wlan0” type device names we’ve been using everywhere for decades.

    Another way to check for cable connection is, (from a root shell):
    ifconfig
    Look for “UP” in the output after the device you want to check (eg eth0)

  • Gurudatta N.R

    How to check the network cable is connected/patched in Linux

    You can test Link by it by running mii-tool

    Example

    # mii-tool
    eth0: negotiated 100baseTx-FD flow-control, link ok
    eth1: autonegotiation restarted, no link
    eth2: autonegotiation restarted, no link
    eth3: autonegotiation restarted, no link

    How to check the network cable is connected or not in the linux

    for cable in `ls /sys/class/net | grep ^eth`; do printf “$cable: “; cat /sys/class/net/$cable/carrier; done

    if 0(blank) = it would mean cables not connected or unplugged
    if 1 = cable connected, plugged

    more eth0/flags; more eth1/flags; more eth2/flags ; more eth3/flags
    0x1003 << connected
    0x1002
    0x1002
    0x1002