for i in /sys/class/net/*; do e=`basename $i`; echo "# $e"; sudo ethtool $e | grep -E "Link|Speed" ; done

Get a summary of network devices in the system

Basically an improvement on an earlier ethtool command line.
Sample Output
# eth0
	Speed: Unknown! (65535)
	Link detected: no
# eth1
	Speed: 100Mb/s
	Link detected: yes
# lo
	Link detected: yes
# pan0
	Link detected: yes
# tap1
	Speed: 10Mb/s
	Link detected: no

0
By: hank
2009-04-25 14:32:08

These Might Interest You

  • Shows how many Windows and Linux devices are on your network. May add support for others, but that's all that are on my network right now. Show Sample Output


    3
    sudo nmap -F -O 192.168.1.1-255 | grep "Running: " > /tmp/os; echo "$(cat /tmp/os | grep Linux | wc -l) Linux device(s)"; echo "$(cat /tmp/os | grep Windows | wc -l) Window(s) devices"
    matthewbauer · 2010-01-10 03:09:56 2
  • Find installed network devices. Show Sample Output


    1
    sudo lshw -C network
    cantormath · 2012-06-07 10:32:49 0

  • 6
    nmap --iflist
    bandie91 · 2013-06-22 10:50:43 1
  • In the field, I needed to script a process to scan a specific vendor devices in the network. With the help of nmap, I got all the devices of that particular vendor, and started a scripted netcat session to download configuration files from a tftp server. This is the nmap loop (part of the script). You can however, add another pipe with grep to filter the vendor/manufacturer devices only. If want to check the whole script, check in http://pastebin.com/ju7h4Xf4 Show Sample Output


    0
    nmap -sP 10.0.0.0/8 | grep -v "Host" | tail -n +3 | tr '\n' ' ' | sed 's|Nmap|\nNmap|g' | grep "MAC Address" | cut -d " " -f5,8-15
    jaimerosario · 2014-12-26 18:31:53 0
  • ethstatus part of ethstatus package, is a consolle based monitor for network interfaces. Nicely display on screen a real time summary about bandwidth, speed and packets.


    6
    ethstatus -i eth0
    servermanaged · 2009-05-09 19:33:39 0
  • Give the Speed and Link status of eth# 0-3. This is sort of what mii-tool does, but eth-tool is better, yet lacks device discovery. Show Sample Output


    6
    for M in 0 1 2 3 ; do echo eth$M ;/sbin/ethtool eth$M | grep -E "Link|Speed" ; done
    Wubby · 2009-04-22 19:32:41 3

What Others Think

Again, your way of using "ls" inside a for loop is inappropriate. Just don't. for i in /sys/class/net/*; do ...
ubersoldat · 473 weeks and 4 days ago
give the guy some credit. this is still awesome.
linuxrawkstar · 473 weeks and 3 days ago
So let's make things straight. This is the corrected line: for i in `ls --color=none /sys/class/net/*`; do echo "# $i"; sudo ethtool $i | grep -E "Link|Speed" ; done
dotanmazor · 473 weeks and 1 day ago
What? This can't work like that. It will pass the whole path to ethtool and fail. You should have the command cd into /sys/class/net before doing an ls, a such: for i in `cd /sys/class/net ; ls -d *`; do ...
tduvally · 351 weeks and 6 days ago
Just fixed it - thanks for the suggestions.
hank · 351 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: