[lug] Newbie Column #7 - In Unix Everything is a File

Wayde Allen wallen at boulder.nist.gov
Mon Feb 28 14:21:11 MST 2000


On Sat, 26 Feb 2000, bill ehlert wrote:

>     i'm familiar with the concept.  but every
>     mention of it that i can recall seeing says
>     approx what you've said  -- and then stops.
> 
>     it seems to me that there must be some fundamental
>     differences between a "file" whose input appears
>     on the monitor and a "file" whose input is stored
>     on disk, can be manipulated an indefinite number
>     of times with an editor, etc.
> 
>     to put it another way, there must be something
>     going on at a "lower" layer; on this layer
>     the two differnet kinds of files must be different
>     things indeed.
> 
>     would you care to offer a few words toward
>     clearing up this mystery?

There are fundamental differences in the way a particular device deals
with or represents a file.  The CRT paints characters on the screen with
an electron beam for instance, whereas the hard drive stores these same
data as magnetic domains on the disk platter.  In that sense, yes the file
has different "physical realizations".  However, the conceptual
realization of these data are not really changed.  In other words, that
letter to your mother is still a letter to your mother independent of how
each device physically realizes it. 

If you go back to my first newbie column
http://archive.lug.boulder.co.us/bymonth/2000.01/msg00334.html.  I pointed
out, it is the Unix kernel that encapsulates the physical hardware.  This
is where the physical differences between each of the pieces of hardware
are dealt with.  It is also why we find ourselves having to compile our
own kernels or install modules into the kernel to support our various
pieces of hardware.  Once the kernel "wraps" or encapsulates the physical
hardware you talk to the hardware by writing a file to the appropriate
device file (take a look at your /dev directory). Some devices such as
CRT's can't be read from, but to display something you just write a file
to the CRT device.

Of course, we could also talk about the "meaning" of the contents of a
file.  For instance, it wouldn't make sense to send a compiled C object
file to your printer since your printer more than likely wouldn't
"understand" the content.  That is really a different discussion, and
doesn't change the fact that essentially everything has a file
representation in the Unix environment. 

- Wayde
  (wallen at boulder.nist.gov)







More information about the LUG mailing list