“Everything is a file” is what made me start understanding linux few years ago and from there it got easier to use with each new concept.

Still this was really revolutionary to me when I first heard it. Made a bunch of things just click.

  • Mr.Chewy@lemmy.world
    link
    fedilink
    arrow-up
    24
    ·
    6日前

    I may be dumb, been on linux too long or a combination of both. But what other way is there, does windows work differently? (regarding that)

    • rtxn@lemmy.worldM
      link
      fedilink
      arrow-up
      58
      ·
      edit-2
      6日前

      “Everything is a file” means that many of the system’s components are represented as abstractions in the filesystem. It’s simply an API that allows reading from and writing to it by integrating into the hierarchical file structure.

      If you take a look inside /sys, you will find a fuckton of files, but they don’t represent data stored on a mass storage medium. Instead, the directory contains a mounted sysfs filesystem that contains file-like representations of various parts and properties of the system. For example, you can read them like a file by running cat /sys/block/sda/queue/rotational to check if the sda block device is a spinning disk (1) or solid-state storage (0). Or you can write to them like a file by running echo 1 > /sys/block/sda/devices/delete to command sda’s driver to detach the device. Similarly, /proc contains a mounted procfs filesystem that presents information about running processes as file-like entries; /dev contains a mounted devfs that points to various devices; and /tmp and /run contain tmpfs mounts for temporary storage in volatile memory (RAM or swap).

      Windows uses various other APIs (like the Component Object Model and others) to accomplish the same that are not necessarily tied into the filesystem.

      • TimeSquirrel@kbin.melroy.org
        link
        fedilink
        arrow-up
        24
        ·
        6日前

        Exactly the same concept as memory-mapped hardware I/O, or virtual file system drivers. Makes it so you don’t have to think too much about implementation details and uses a common interface that’s already there.

        • ByteJunk@lemmy.world
          link
          fedilink
          arrow-up
          11
          ·
          5日前

          Sensible, yes.

          But this is alien tech in windows land, if you’re reading some device status or something, you need a special app for that.

      • Mind you, the registry is also just a couple of files that are shown to the user as “the registry”. IIRC, on Windows, go into the user account’s root folder, and you’ll have NTUSER.dat. That’s the HKCU hive for that user.

        • Peruvian_Skies@sh.itjust.works
          link
          fedilink
          arrow-up
          7
          ·
          6日前

          And that’s precisely the difference. In both cases the configuration is data stored on disk but Linux presents it as files while Windows presents it as a registry tree. In Windows, you’re not supposed to edit the registry by interacting with NTUSER.dat as a file.