Wednesday, September 11, 2013

Everything is a File

The first thing that needs to be understood about the design philosophy of linux is that everything in the system can be represented as a file. Not necessarily everything IS represented this way, but everything can be. So, in a very real sense, everything in linux is a file. This applies to actual files, directories/folders, sections of active memory, configurable parameters of the kernel, actual hardware devices, processes and information about them, network connections, everything. This page goes into a bit more depth: http://wiki.freegeek.org/index.php/Everything_is_a_File

This design philosophy is an offshoot of the unix philosophy, where if a program is worth writing, that program will do one thing, and it will do that one thing very very well. If you need it to do a second thing, write a second program to handle that second thing. If you *really* need a program to do two things, write three programs. One do to thing one, another to do thing two, and a final one to call the other two. Having small single purpose programs necessitates that programs be capable of communicating with each other, and where there is communication there must also be an agreed upon format for that communication. Unix chose to use the concept of a stream of bytes as that form of communication, and files are in a literal sense a stream of bytes. Thus, everything is a file, and all programs should do one thing, do that one thing well, and be capable of communicating through files. See here for more information on the unix philosophy: http://en.wikipedia.org/wiki/Unix_philosophy

No comments:

Post a Comment