Take the 2-minute tour ×
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
add comment

7 Answers

up vote 19 down vote accepted

ethtool ethX

for example

ethtool eth0 or ethtool eth1

provides

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 pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000001 (1)
        Link detected: yes
share|improve this answer
add comment

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
add comment

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
4  
/sys/class/net/eth0/carrier was the perfect answer to this question for me. –  Per Knytt Apr 29 '11 at 15:32
add comment
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
    
I think this was the best answer - ethtool isn't standard in my Ubuntu distibution, so it doesn't help if on a box not connected to the net. –  user20010 Sep 25 '13 at 21:32
add comment
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 '13 at 15:30
    
dmesg requires root on Slackware 14.0 –  AnonymousLurker Aug 30 '13 at 14:20
add comment

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
add comment

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

share|improve this answer
add comment

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.