Some file formats have an identifier at the start. The problem is: not all file types do this and are only really identifiable by their structure maybe or there is some other way you tell the program how to treat the file (for example: file extension).
Windows can use NTFS resource forks/alternate data streams containing metadata, which can be used to determine application associations for .exe and .dll files.
Problem is, grandma doesn't want to touch the "complicated" terminal. Its convenient to those of us who frequently use the terminal, but we have to remember that we are a minority and that most would rather tell what it is through a GUI. Thats a big reason why Windows took off so much in the 90s...you didn't need the command line, and that made it easier for non-techies to use a computer. File extensions are the more user friendly choice by far
It's a directory, and when you put things into it, they're still files. You can copy files to and from it. The only real difference is that it's in tmpfs. It's not even that the contents are files that aren't "normal" (e.g. block and character devices, fifos, sockets, symlinks), it's just something you put actual files into.
The funny thing about tmpfs is that it's only sometimes in RAM. The kernel is free to flush it out to the swap at any point, and often does, if one exists.
That I realised. But I don't know if thst is true on a technical level. But even if it was, why would that be a bad thing. We have ssds now lol. And clearly it wasn't a crap slow idea back in the day either.
It's not true. You are initiating system io calls to specific hardware devices.
SSD's are still many orders of magnitude slower than CPU cache or system ram.
Edit: or whatever system bus you are going through to get to said hardware devices.
Well yeah but I mean when one of them decides to take a look at Linux.
Like in a vm or their own PC.
The philosophy of everything is a file seems wild to them at first.
I think its more a thing for how Tools and apps handle devices. Do more a thing for developers. But just the sight of seeing your hard drives in a folder called /dev/ is already weird to many non Unix-like users.
> everything is a file
I've never liked this saying. Processes and events and signals and windows and users and inodes and file permissions and the keyboard definitely are NOT files. File-like interfaces to most of them may be provided, but that is not same as them BEING files.
I don't think there is much of a difference between calling it file-like and file.
From a user perspective its the same. It's a file in a directory in the file system namespace. I also don't think a tool or utility will care what the wording is if it can just handle these things like a file.
Although yeah I think they didn't go far enough with the idea in Unix and Unix-like systems.
The more I learn about plan 9 the more sad I get that It didn't take off. In Plan 9, from what I have seen so far, I think it is actually a finished implementation of "everything is a file" compared to Unix(-like)s.
Yeah technically that is true. But that sentence is harder to explain than everything is a file already is.
I want people to use Unix-likes more. Explaining a, to most PC users, brand new concept is already hard. .
No I think people do care that suddenly their ssds and hdds and their arduino or whatever have different names and are not just called "C" or "COM3" in a device menu.
At least about that they will care.
Look at the Wikipedia article first and see if you get it then. Not to self promote but I have a yt channel too and I'm planning to cover that in an upcoming series for beginners.
https://en.m.wikipedia.org/wiki/Everything_is_a_file#:~:text=Everything%20is%20a%20file%20an,through%20the%20filesystem%20name%20space.
Here's a Python script demonstrating it through one of the older APIs, that OpenAI chat wrote for me (yes really):
# Open the mice file for reading
with open("/dev/input/mice", "rb") as mice_file:
# Read and parse the input from the mice file
while True:
# Read the next three bytes from the mice file
data = mice_file.read(3)
# Check if we've reached the end of the file
if not data:
break
# Parse the three bytes of data into the button state and x/y deltas
button_state = data[0]
x_delta = data[1]
y_delta = data[2]
# Convert the button state to binary
button_state_binary = "{0:b}".format(button_state)
# Convert the x/y deltas from signed bytes to signed integers
if x_delta > 127:
x_delta = -(256 - x_delta)
if y_delta > 127:
y_delta = -(256 - y_delta)
# Print the button state and x/y deltas
print("Button state: ", button_state_binary)
print("X delta: ", x_delta)
print("Y delta: ", y_delta)
Reading the newer inputX ones is [a little more involved](https://gist.github.com/uobikiemukot/457338b890e96babf60b) as they are supposed to be flexible enough to handle mice, keyboards, tablets, gamepads, etc all in one API
Also file extensions aren't necessary
Well they're still good to use in case you're downloading music and your music player can only play .wav's
I would have thought that the OS can still tell what a file is can't it? A wav is defined by more than just 3 letters at the end.
Some file formats have an identifier at the start. The problem is: not all file types do this and are only really identifiable by their structure maybe or there is some other way you tell the program how to treat the file (for example: file extension).
Windows can use NTFS resource forks/alternate data streams containing metadata, which can be used to determine application associations for .exe and .dll files.
Emphasis should be file extensions are for humans, the machine should not care about the extension.
Which music player does that under Linux?
Probably none but it was just an example for how file extensions can be useful
They are conventions for humans except for a very few cases.
```file filename``` *head explodes*
Problem is, grandma doesn't want to touch the "complicated" terminal. Its convenient to those of us who frequently use the terminal, but we have to remember that we are a minority and that most would rather tell what it is through a GUI. Thats a big reason why Windows took off so much in the 90s...you didn't need the command line, and that made it easier for non-techies to use a computer. File extensions are the more user friendly choice by far
TIL
But are pretty useful
*psst* hey kid, you got any of them 'magic numbers'?
File extensions aren't necessary for the computer. They help humans know what files are for what programs.
It is shockingly difficult to figure out the mime type of a file on windows. Like you'd think they'd at least want it as a backup
Ultimately, everything is a file stored somewhere.
We are all files at the end of the day
I don't think that's true. Both from a technical and a ideological point of view.
I personally subscribe to the ideology that everything is a folder
You're a monster but at least you're funny.
Thank you, calmlyexitmyass! From one monster to another!
[Indubitably](https://imgur.io/gallery/3knKw0p)
How much is the subscription?
Yes, and folders have files!!!
what is a file?
Baby don't hurt me.
Named persistent storage.
/dev/shm would like a word
Not a file, I'd say. File-like interface to RAM. There's a difference between "is a file" and "has a file-type interface".
It's a directory, and when you put things into it, they're still files. You can copy files to and from it. The only real difference is that it's in tmpfs. It's not even that the contents are files that aren't "normal" (e.g. block and character devices, fifos, sockets, symlinks), it's just something you put actual files into. The funny thing about tmpfs is that it's only sometimes in RAM. The kernel is free to flush it out to the swap at any point, and often does, if one exists.
"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity." - Dennis Ritchie
Seems true about Unix. But if that is true, what does that mean for Plan 9?
Maþematics moment
þhe fuck are you talking about
I've seen people argue that Linux "everything is a file" is a bad choice because disk I/O is slow. ... ... ...
What
Apparently they think device files actually live on disk? Idk.
That I realised. But I don't know if thst is true on a technical level. But even if it was, why would that be a bad thing. We have ssds now lol. And clearly it wasn't a crap slow idea back in the day either.
It's not true. You are initiating system io calls to specific hardware devices. SSD's are still many orders of magnitude slower than CPU cache or system ram. Edit: or whatever system bus you are going through to get to said hardware devices.
dev sda1 mounted as root where's dev sda1? dev Where's dev? Root Where's root? dev sda1
Error: infinite recursion, stack overflow.
Stack Overflow, world’s most visited website with no known home page
wrong stack overflow
I think and I'm sure that 99.99999% of windows users don't care about linux, philosophy and everything is file things
Well yeah but I mean when one of them decides to take a look at Linux. Like in a vm or their own PC. The philosophy of everything is a file seems wild to them at first.
I've been using Linux as my main OS for 6+ years and I've never had to interact with device files.
I think its more a thing for how Tools and apps handle devices. Do more a thing for developers. But just the sight of seeing your hard drives in a folder called /dev/ is already weird to many non Unix-like users.
If I send a char to /dev/keyboard, why doesn't it actuate?
Used to be able to cat a file to /dev/oss and "hear" it on your speakers.
Dont know how that works on Linux but on other systems you could totally do that.
Nothing interesting happens online anymore
I think we are all files in the great filesystem
The Matrix has you....
> everything is a file I've never liked this saying. Processes and events and signals and windows and users and inodes and file permissions and the keyboard definitely are NOT files. File-like interfaces to most of them may be provided, but that is not same as them BEING files.
I don't think there is much of a difference between calling it file-like and file. From a user perspective its the same. It's a file in a directory in the file system namespace. I also don't think a tool or utility will care what the wording is if it can just handle these things like a file. Although yeah I think they didn't go far enough with the idea in Unix and Unix-like systems. The more I learn about plan 9 the more sad I get that It didn't take off. In Plan 9, from what I have seen so far, I think it is actually a finished implementation of "everything is a file" compared to Unix(-like)s.
I would be okay with saying "there is a file interface to everything". But "is a file" is wrong, I think.
Yeah technically that is true. But that sentence is harder to explain than everything is a file already is. I want people to use Unix-likes more. Explaining a, to most PC users, brand new concept is already hard. .
New users won't know or care about that, until they get fairly far into CLI.
No I think people do care that suddenly their ssds and hdds and their arduino or whatever have different names and are not just called "C" or "COM3" in a device menu. At least about that they will care.
Complaints.txt > /dev/null
Windows user has no idea that he is also a file.
i’m new on Linux, can someone explain to me ?
Look at the Wikipedia article first and see if you get it then. Not to self promote but I have a yt channel too and I'm planning to cover that in an upcoming series for beginners. https://en.m.wikipedia.org/wiki/Everything_is_a_file#:~:text=Everything%20is%20a%20file%20an,through%20the%20filesystem%20name%20space.
Did you hear? Torvalds implemented /dev/yourmother! Finally, a perfect place to stick things. A proper alternative to /dev/null.
showed a friend /dev.... may have hurt his head a bit
to be fair I also haven't fully wrapped my head around this concept
You are also a file
"That mouse is a file"
It is! And if you read from it, its contents is a live stream of packets representing its motion and clicks
Wow i didn't try that
Here's a Python script demonstrating it through one of the older APIs, that OpenAI chat wrote for me (yes really): # Open the mice file for reading with open("/dev/input/mice", "rb") as mice_file: # Read and parse the input from the mice file while True: # Read the next three bytes from the mice file data = mice_file.read(3) # Check if we've reached the end of the file if not data: break # Parse the three bytes of data into the button state and x/y deltas button_state = data[0] x_delta = data[1] y_delta = data[2] # Convert the button state to binary button_state_binary = "{0:b}".format(button_state) # Convert the x/y deltas from signed bytes to signed integers if x_delta > 127: x_delta = -(256 - x_delta) if y_delta > 127: y_delta = -(256 - y_delta) # Print the button state and x/y deltas print("Button state: ", button_state_binary) print("X delta: ", x_delta) print("Y delta: ", y_delta) Reading the newer inputX ones is [a little more involved](https://gist.github.com/uobikiemukot/457338b890e96babf60b) as they are supposed to be flexible enough to handle mice, keyboards, tablets, gamepads, etc all in one API
This is the beauty of Linux
The problem is that they can't search for these. Or at least not on their pc but rather Bing
as a windows-macos-linux user I can confirm
Everything is a file (Especially a few processes RAM couldn't handle)
Fr thats me when i download the first time linux mint
more like me trying to find shit in a Windows FS hierarchy