“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.

  • Janet@lemmy.blahaj.zone
    link
    fedilink
    arrow-up
    4
    ·
    3 hours ago

    it’s all fun and games until you want to use your mouse and keyboard inputs on another machine and also view the other machines screen contents. then all of a sudden stuff stops being a file. quaint.

    if only there was a way to share resources over a network…

      • mumblerfish@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        2 hours ago

        What do you mean? This

        remoteuser@server$ nc -l -p 4444 > /dev/input/event0
        
        
        localuser@laptop$ cat /dev/input/event0 | nc server 4444
        

        doesn’t work?

  • Mr.Chewy@lemmy.world
    link
    fedilink
    arrow-up
    11
    ·
    5 hours ago

    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
      25
      ·
      edit-2
      4 hours ago

      “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
        9
        ·
        3 hours ago

        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.

    • witty_username@feddit.nl
      link
      fedilink
      arrow-up
      14
      ·
      4 hours ago

      I think the meme mostly refers to configuration. In Linux configurations are stored as plain text files. Windows uses the registry for many configurations.

        • drosophila@lemmy.blahaj.zone
          link
          fedilink
          English
          arrow-up
          22
          ·
          edit-2
          4 hours ago

          Anyone interested in this concept should take a look at plan9. Everything is even more of a file there.

          Taking a screenshot, for example, can be done with:

          cat /dev/screen | topng > screenshot.png

          That combined with the way that parent processes can alter their children’s view of the filesystem namespace allows for extremely elegant abstractions. For example, every program just tries to write directly to screen or audio, but the desktop environment redirects their writes to the relevant servers. Which means that, in the absence of those servers, those same programs can run just fine and don’t care whether they’re being multiplexed or not. That also means that the plan9 userspace can be nested inside itself just using the normal mechanisms of how the OS works (that is, without a special tool like Docker).

      • Zagorath@aussie.zone
        link
        fedilink
        arrow-up
        8
        ·
        4 hours ago

        That might be part of it, but I was thinking it was more how things we don’t think of as files, like sockets, are accessed with a file descriptor.

        • Badabinski@kbin.earth
          link
          fedilink
          arrow-up
          1
          ·
          36 minutes ago

          Hell, Bash provides filesystem-based sockets in /dev/tcp, so a tcp connection can almost be like Unix sockets or anything else.

          I always found it weird that it was specifically provided by Bash…

      • unknownuserunknownlocation@kbin.earth
        link
        fedilink
        arrow-up
        3
        ·
        4 hours ago

        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
          5
          ·
          2 hours ago

          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.

    • JayDee@lemmy.sdf.org
      link
      fedilink
      arrow-up
      8
      ·
      edit-2
      2 hours ago

      It’s more a philosophy for Unix systems. When we say that “everything is a file”, we’re saying that even devices should show up on the filesystem (/dev), even network ports should show up on the filesystem, even processes should show up on the filesystem(/proc), etc… and that is as opposed to having a different system abstraction handle those functions instead.

      Of course when you look deeper into it, linux does not explicitly follow that rule, it more just adheres to it. It’s more a guideline than an explicit statement of fact

    • Zagorath@aussie.zone
      link
      fedilink
      arrow-up
      3
      ·
      4 hours ago

      Yeah I’m interested in how that works too.

      I’ve recently been looking at the Nextcloud “all in one” Docker image. It works by mounting the docker.sock file into the master container, which allows that container to stand up a whole bunch of other containers on your machine.

      How would that work on Windows, if the Docker socket isn’t a file handle?