I want to check if a specified ethX is physically up or down. How do I do that with the command line?

link|improve this question

74% accept rate
feedback

7 Answers

up vote 10 down vote accepted

ethtool ethX

link|improve this answer
feedback

ethtool [interface]

last line shows what you want:

# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Current message level: 0x00000037 (55)
        Link detected: yes
link|improve this answer
1  
If you check this: en.wikipedia.org/wiki/OSI_model . You will see that the last line is about another layer: the link layer. I just tested this. With a bad cable the physical layer was up, but not the link layer. Then I switched to another cable and all layers came up. – Jader Dias May 30 '09 at 19:37
feedback

You can also use mii-tool to see if the link is up and check the negotiated speed.

# mii-tool
eth0: negotiated 100baseTx-FD, link ok

link|improve this answer
3  
mii-tool is deprecated and does not work for GbE interfaces. – Dave Cheney May 31 '09 at 3:59
@DaveCheney # mii-tool eth0: negotiated 1000baseT-FD flow-control, link ok – stolsvik Jul 21 '11 at 11:00
feedback
ip link show

is another. Good old

ifconfig dev_name

or

ifconfig -a

will also tell you if the interface is up

link|improve this answer
feedback

Check /sys/class/net/eth0/operstate and other files in this directory

As far as I know this is specific to Linux 2.6 but provides a clean interface to the kernel driver.

link|improve this answer
3  
/sys/class/net/eth0/carrier was the perfect answer to this question for me. – Per Ekman Apr 29 '11 at 15:32
feedback
dmesg | grep eth

you should see all statuschanges

link|improve this answer
feedback

netplugd is a service that can run program(s) when a cable is plugged in or a cable taken out.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.