8

Generally I have noticed that plugging in a new device in a Linux system causes a new entry to be listed in /dev (assuming you have the correct drivers).

For example:

  1. When you plug in a new hard drive you get /dev/sdb.
  2. When you plug in a serial device you get /dev/ttyS0.

When I plug in an Ethernet device, why don't I get something like /dev/eth0?

Is there a device listing for Ethernet ports?

I know you can see port names using ifconfig, I am just wondering if something shows up in /dev too.

1

3 Answers 3

9

It's a good question. The reason is essentially historical; different groups with different goals and priorities added pieces of Unix over time, and the differences among various APIs are a reflection of this history. I think the original device file concept goes back to Bell Labs, whereas network sockets were added later at UC Berkeley. Bell was trying to create a nice clean maintainable paradigm for AT&T's operations, whereas Berkeley needed to add internet features that didn't fit easily into that paradigm. Technically it would be possible to go back and create a /dev/eth0 file today (see below), but it would involve rewriting a prohibitive amount of legacy code.

Slight OT: If the subject interests you, consider taking a look at Plan 9, which took "everything is a file" to greater extremes (just don't expect it to have very many modern, usable applications):

http://www.faqs.org/docs/artu/plan9.html

many facilities that under Unix are accessed through various ad-hoc interfaces like BSD sockets, fcntl(2), and ioctl(2) are in Plan 9 accessed through ordinary read and write operations on special files analogous to device files

1
  • 1
    thanks for your insight! That really is too bad. To me, it feels like a really odd quirk in an otherwise great device management system.
    – dinkelk
    Jun 11, 2013 at 2:13
0

Hello nowadays the /dev directory is populated by udev, a daemon that reads the /sys directory, and create those files. If you want to use fdisk and gdisk, you are forced to use devices found in /dev. And to see the the tty and pty used. I think BSD allocates an ethernet interface in /dev, where you can write and read to.

0

Not so long ago Ethernet devices did appear as /dev/eth0, /dev/eth1 and so on. There are still applications that expect to find them there, but are now disappointed and sometimes unusable. Fortunately not too many.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .