Tell me more ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

7 Answers

up vote 13 down vote accepted

ethtool ethX

share|improve this answer

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
share|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

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.

share|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
ip link show

is another. Good old

ifconfig dev_name

or

ifconfig -a

will also tell you if the interface is up

share|improve this answer

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

share|improve this answer
4  
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
dmesg | grep eth

you should see all statuschanges

share|improve this answer
This is the only one that works if one lacks admin privileges. – Brian B Mar 20 at 15:30

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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