Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm aware that I can use ethtool eth0|eth1|eth2 to check the existence of a NIC. But I wonder where the files are on the machine that contain information of an existing interface, as I need to use the Ruby language to check for available NICs.

share|improve this question
up vote 1 down vote accepted

There is /proc/net/dev, but I am sure there is an actual Ruby API to do this correctly.

see http://curioushq.blogspot.com/2011/04/listing-all-network-interfacesdevices.html

share|improve this answer
Great! Thanks a lot. – Terry Li Jul 20 '11 at 17:16

Call ethtool as an external process and parse its output. If you want information related to IP settings, call ifconfig in preference to ethtool, because ifconfig is always present whereas ethtool will be present only if the system administrator has installed it. An alternative to ifconfig is ip, but it's not always present and its output is only marginally easier to parse than ifconfig's, so use ifconfig if it provides the right output for you.

share|improve this answer

Your Answer


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.