Everything may be a file, but not everything is real.
Consider the contents of /proc
. On my Linux system, there is a file /proc/uptime
, whose current contents are:
831801.89 1241295.64
If I were to cat
the file again, it would contain different numbers. My hard drive is mounted read-only, so it can't possibly be the case that something is writing these numbers to disk every fraction of a second.
In fact, nothing under /proc
is on disk. Each interaction with a file in that directory simply runs kernel code, due to the nature of procfs
.
Then there are temporary files. Chances are, your /tmp
is mounted tmpfs
, meaning its contents are stored in RAM instead of on disk.
Another interesting place is /dev/tcp
, for communicating with the network. On some systems, this only even exists under bash
but not other shells, so it can't possibly be on-disk in those systems.
These examples all show that the filesystem and the hard drive are separate, and the "Everything is a file" philosophy does not impact performance on account of I/O speed.
/net/https://unix.stackexchange.com/questions/360212/is-linux-everything-is-a-file-reducing-performance
that could contain this page. This page is not on your hard-disk, so not a file in that sense. So in what sense, everything looks like a file. Everything has a file interface. In the same way that (nearly) all motor vehicles have the same controls: steering wheel, peddles in the same place, same-ish gear stick. – ctrl-alt-delor Apr 20 '17 at 16:12