Although you'll hear the "everything is a file" is a Unix design philosophy, as Wikipedia notes it is really more accurate to say that in Unix "Everything is a file descriptor".
I've said similar things myself, usually explaining that it's an abstraction, that everything *looks like* a file to a programmer. That is realistic. It's a programmers reality; outside of programming, this abstraction doesn't really matter.
It's also true that it depends on how you look at things. Linus Torvalds opined a slightly different take in this thread:
What do you think "a file" is? In UNIX, a file descriptor is pretty much anything. You could say that sockets aren't remotely file-like, and you'd be right. What's your point? If you can read on it, it's a file.
See what I mean? Programmer's reality.
Still other people prefer other terms. In The Art of Unix Programming, Eric Raymond expresses it this way:
In earlier operating systems, devices were very special thing. If you wanted to write to a printer or a tape, you had to ask the operating system to do that in your program. There was no concept of a "device" that you could just open and read or write at will.
Naming is an important part of that ability, of course. See The Hideous Name by Rob Pike and P.J. Weinberger and Ghosts of Unix Past: a historical search for design patterns for more on that.
Some people get downright angry about "everything is a file". Here's a rant from 10 Things I Hate About (U)NIX:
He's obviously misunderstood the meaning; learning the limits of abstractions is often the hardest part of understanding anything. And of course you CAN send an image to a terminal and display the bytes with "od" - and which is the proper representation: the visual on a graphics screen or the raw bytes? Both are legitimate. The artist would say it's the screen display, the programmer would insist it is the bytes.
Again, it's just a programmers view of their reality. Everything in Unix looks like a file to a programmer and that's where this expression came from. It's not meant to be taken literally outside of programming (and yes, of course scripting and creating pipes at the command line is programming).
Got something to add? Send me email.
More Articles by Anthony Lawrence © 2013-07-30 Anthony Lawrence