Why every device in Linux is a file or folder ? what are the advantages? [on hold]2019 Community Moderator ElectionA layman's explanation for “Everything is a file” — what differs from Windows?Device names for logical volumesstuck at “make install”Disk size managementWhat are the advantages of the Unix file system structureWhat are the advantages / disadvantages Linux file hierarchy has compared to other OSs?How to make sure that certain devices always use the same device file?What filesystems should I use on grub and ESP?What happens if you delete a device file?What is good block size for file cache on Linux?grub2 error disk 'hd0,msdos1' not found, ls shows no disk
Visiting the UK as unmarried couple
Is there enough fresh water in the world to eradicate the drinking water crisis?
Adding empty element to declared container without declaring type of element
Lightning Web Component - do I need to track changes for every single input field in a form
Superhero words!
Is infinity mathematically observable?
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Indicating multiple different modes of speech (fantasy language or telepathy)
Can I rely on these GitHub repository files?
Can I Retrieve Email Addresses from BCC?
Why isn't KTEX's runway designation 10/28 instead of 9/27?
Can I use my Chinese passport to enter China after I acquired another citizenship?
Why are all the doors on Ferenginar (the Ferengi home world) far shorter than the average Ferengi?
Do all polymers contain either carbon or silicon?
Greatest common substring
My boss asked me to take a one-day class, then signs it up as a day off
Can I create an upright 7-foot × 5-foot wall with the Minor Illusion spell?
Is exact Kanji stroke length important?
What is the term when two people sing in harmony, but they aren't singing the same notes?
Stereotypical names
What does the "3am" section means in manpages?
Java - What do constructor type arguments mean when placed *before* the type?
Is there a good way to store credentials outside of a password manager?
I2C signal and power over long range (10meter cable)
Why every device in Linux is a file or folder ? what are the advantages? [on hold]
2019 Community Moderator ElectionA layman's explanation for “Everything is a file” — what differs from Windows?Device names for logical volumesstuck at “make install”Disk size managementWhat are the advantages of the Unix file system structureWhat are the advantages / disadvantages Linux file hierarchy has compared to other OSs?How to make sure that certain devices always use the same device file?What filesystems should I use on grub and ESP?What happens if you delete a device file?What is good block size for file cache on Linux?grub2 error disk 'hd0,msdos1' not found, ls shows no disk
Why every device in Linux is a file or folder ? what are the advantages ? and
what is the necessity of /dev/sda1
, /dev/sda2
or /dev/sda3
file ? it's size is 0 bytes .and after mounting the hard disk the files are located in /media
folder . why /dev/sda1
or such files necessary?
linux filesystems devices
New contributor
put on hold as too broad by heemayl, Kusalananda, Stephen Harris, jimmij, Jeff Schaller yesterday
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
Why every device in Linux is a file or folder ? what are the advantages ? and
what is the necessity of /dev/sda1
, /dev/sda2
or /dev/sda3
file ? it's size is 0 bytes .and after mounting the hard disk the files are located in /media
folder . why /dev/sda1
or such files necessary?
linux filesystems devices
New contributor
put on hold as too broad by heemayl, Kusalananda, Stephen Harris, jimmij, Jeff Schaller yesterday
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Welcome to U&L! Folders (directories) are files as well. Apart from that, your question is comprised of multiple questions which makes this too broad to answer. Please ask a single question at a time. Good luck.
– heemayl
2 days ago
thanks for replaying @heemayl . questions were spinning around my head that's why I posted all the questions at once . if I won't get any good answer then I definitely post the question in parts. thanks again . BTW I am from Bangladesh too
– sabbir
2 days ago
Great! Nice to see you here :)
– heemayl
2 days ago
What would the alternative be?
– Kusalananda
2 days ago
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
2 days ago
add a comment |
Why every device in Linux is a file or folder ? what are the advantages ? and
what is the necessity of /dev/sda1
, /dev/sda2
or /dev/sda3
file ? it's size is 0 bytes .and after mounting the hard disk the files are located in /media
folder . why /dev/sda1
or such files necessary?
linux filesystems devices
New contributor
Why every device in Linux is a file or folder ? what are the advantages ? and
what is the necessity of /dev/sda1
, /dev/sda2
or /dev/sda3
file ? it's size is 0 bytes .and after mounting the hard disk the files are located in /media
folder . why /dev/sda1
or such files necessary?
linux filesystems devices
linux filesystems devices
New contributor
New contributor
edited 2 days ago
Rui F Ribeiro
41.7k1483142
41.7k1483142
New contributor
asked 2 days ago
sabbirsabbir
12
12
New contributor
New contributor
put on hold as too broad by heemayl, Kusalananda, Stephen Harris, jimmij, Jeff Schaller yesterday
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as too broad by heemayl, Kusalananda, Stephen Harris, jimmij, Jeff Schaller yesterday
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
Welcome to U&L! Folders (directories) are files as well. Apart from that, your question is comprised of multiple questions which makes this too broad to answer. Please ask a single question at a time. Good luck.
– heemayl
2 days ago
thanks for replaying @heemayl . questions were spinning around my head that's why I posted all the questions at once . if I won't get any good answer then I definitely post the question in parts. thanks again . BTW I am from Bangladesh too
– sabbir
2 days ago
Great! Nice to see you here :)
– heemayl
2 days ago
What would the alternative be?
– Kusalananda
2 days ago
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
2 days ago
add a comment |
Welcome to U&L! Folders (directories) are files as well. Apart from that, your question is comprised of multiple questions which makes this too broad to answer. Please ask a single question at a time. Good luck.
– heemayl
2 days ago
thanks for replaying @heemayl . questions were spinning around my head that's why I posted all the questions at once . if I won't get any good answer then I definitely post the question in parts. thanks again . BTW I am from Bangladesh too
– sabbir
2 days ago
Great! Nice to see you here :)
– heemayl
2 days ago
What would the alternative be?
– Kusalananda
2 days ago
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
2 days ago
Welcome to U&L! Folders (directories) are files as well. Apart from that, your question is comprised of multiple questions which makes this too broad to answer. Please ask a single question at a time. Good luck.
– heemayl
2 days ago
Welcome to U&L! Folders (directories) are files as well. Apart from that, your question is comprised of multiple questions which makes this too broad to answer. Please ask a single question at a time. Good luck.
– heemayl
2 days ago
thanks for replaying @heemayl . questions were spinning around my head that's why I posted all the questions at once . if I won't get any good answer then I definitely post the question in parts. thanks again . BTW I am from Bangladesh too
– sabbir
2 days ago
thanks for replaying @heemayl . questions were spinning around my head that's why I posted all the questions at once . if I won't get any good answer then I definitely post the question in parts. thanks again . BTW I am from Bangladesh too
– sabbir
2 days ago
Great! Nice to see you here :)
– heemayl
2 days ago
Great! Nice to see you here :)
– heemayl
2 days ago
What would the alternative be?
– Kusalananda
2 days ago
What would the alternative be?
– Kusalananda
2 days ago
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
2 days ago
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
I'll try to answer the question "Why every device in Linux is a file" specifically geared towards data storage (as the question takes them as an example). More in-depth answers regarding the POSIX philosophy may be interesting, too.
The base concept here is, that virtually every operation in a computer essentially comes down to moving data around. Data is read, transformed and written. Of course, depending on which hardware is origin of the data read or target of the data written, the real-world outcome is totally different.
Historically, popular devices for data storage (assume a hard-drive) were handled by the SCSI driver. That is why storage is commonly prefixed with sd
. You then want a logical "software" representation of the individual physical "hardware" device. You just number them, starting with a
. Concatenated, a hard-drive may be referred to as sda
.
Now you have a "file" which you can read data from (writing is analogous). If you read the first byte from /dev/sda
, you will actually read the byte which is actually sitting on the very beginning of that data storage device (block sizes ignored for the sake of simplicity). You can try this yourself by starting sudo hexdump -C /dev/sda | less
. Of course, most of the content will be gibberish to the naked eye.
However if you interpreted that gibberish so you know where a partition starts and mount that partition, a program (the filesystem driver) interprets the data for you and presents a nice tree-like structure with folders and files you can then read data from in return.
Fun fact: This also holds (to varying degrees) for other kinds of devices (character devices) like keyboards and mice (they "produce" data you can read): sudo hexdump -C /dev/input/mouse0
).
Or the main memory.
Or even the graphics memory (framebuffer): I occasionally enjoy switching to one of the virtual consoles (Ctrl+Alt+F1) and have my graphics card interpret and display random numbers via sudo dd if=/dev/urandom of=/dev/fb0 bs=1M count=1
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'll try to answer the question "Why every device in Linux is a file" specifically geared towards data storage (as the question takes them as an example). More in-depth answers regarding the POSIX philosophy may be interesting, too.
The base concept here is, that virtually every operation in a computer essentially comes down to moving data around. Data is read, transformed and written. Of course, depending on which hardware is origin of the data read or target of the data written, the real-world outcome is totally different.
Historically, popular devices for data storage (assume a hard-drive) were handled by the SCSI driver. That is why storage is commonly prefixed with sd
. You then want a logical "software" representation of the individual physical "hardware" device. You just number them, starting with a
. Concatenated, a hard-drive may be referred to as sda
.
Now you have a "file" which you can read data from (writing is analogous). If you read the first byte from /dev/sda
, you will actually read the byte which is actually sitting on the very beginning of that data storage device (block sizes ignored for the sake of simplicity). You can try this yourself by starting sudo hexdump -C /dev/sda | less
. Of course, most of the content will be gibberish to the naked eye.
However if you interpreted that gibberish so you know where a partition starts and mount that partition, a program (the filesystem driver) interprets the data for you and presents a nice tree-like structure with folders and files you can then read data from in return.
Fun fact: This also holds (to varying degrees) for other kinds of devices (character devices) like keyboards and mice (they "produce" data you can read): sudo hexdump -C /dev/input/mouse0
).
Or the main memory.
Or even the graphics memory (framebuffer): I occasionally enjoy switching to one of the virtual consoles (Ctrl+Alt+F1) and have my graphics card interpret and display random numbers via sudo dd if=/dev/urandom of=/dev/fb0 bs=1M count=1
add a comment |
I'll try to answer the question "Why every device in Linux is a file" specifically geared towards data storage (as the question takes them as an example). More in-depth answers regarding the POSIX philosophy may be interesting, too.
The base concept here is, that virtually every operation in a computer essentially comes down to moving data around. Data is read, transformed and written. Of course, depending on which hardware is origin of the data read or target of the data written, the real-world outcome is totally different.
Historically, popular devices for data storage (assume a hard-drive) were handled by the SCSI driver. That is why storage is commonly prefixed with sd
. You then want a logical "software" representation of the individual physical "hardware" device. You just number them, starting with a
. Concatenated, a hard-drive may be referred to as sda
.
Now you have a "file" which you can read data from (writing is analogous). If you read the first byte from /dev/sda
, you will actually read the byte which is actually sitting on the very beginning of that data storage device (block sizes ignored for the sake of simplicity). You can try this yourself by starting sudo hexdump -C /dev/sda | less
. Of course, most of the content will be gibberish to the naked eye.
However if you interpreted that gibberish so you know where a partition starts and mount that partition, a program (the filesystem driver) interprets the data for you and presents a nice tree-like structure with folders and files you can then read data from in return.
Fun fact: This also holds (to varying degrees) for other kinds of devices (character devices) like keyboards and mice (they "produce" data you can read): sudo hexdump -C /dev/input/mouse0
).
Or the main memory.
Or even the graphics memory (framebuffer): I occasionally enjoy switching to one of the virtual consoles (Ctrl+Alt+F1) and have my graphics card interpret and display random numbers via sudo dd if=/dev/urandom of=/dev/fb0 bs=1M count=1
add a comment |
I'll try to answer the question "Why every device in Linux is a file" specifically geared towards data storage (as the question takes them as an example). More in-depth answers regarding the POSIX philosophy may be interesting, too.
The base concept here is, that virtually every operation in a computer essentially comes down to moving data around. Data is read, transformed and written. Of course, depending on which hardware is origin of the data read or target of the data written, the real-world outcome is totally different.
Historically, popular devices for data storage (assume a hard-drive) were handled by the SCSI driver. That is why storage is commonly prefixed with sd
. You then want a logical "software" representation of the individual physical "hardware" device. You just number them, starting with a
. Concatenated, a hard-drive may be referred to as sda
.
Now you have a "file" which you can read data from (writing is analogous). If you read the first byte from /dev/sda
, you will actually read the byte which is actually sitting on the very beginning of that data storage device (block sizes ignored for the sake of simplicity). You can try this yourself by starting sudo hexdump -C /dev/sda | less
. Of course, most of the content will be gibberish to the naked eye.
However if you interpreted that gibberish so you know where a partition starts and mount that partition, a program (the filesystem driver) interprets the data for you and presents a nice tree-like structure with folders and files you can then read data from in return.
Fun fact: This also holds (to varying degrees) for other kinds of devices (character devices) like keyboards and mice (they "produce" data you can read): sudo hexdump -C /dev/input/mouse0
).
Or the main memory.
Or even the graphics memory (framebuffer): I occasionally enjoy switching to one of the virtual consoles (Ctrl+Alt+F1) and have my graphics card interpret and display random numbers via sudo dd if=/dev/urandom of=/dev/fb0 bs=1M count=1
I'll try to answer the question "Why every device in Linux is a file" specifically geared towards data storage (as the question takes them as an example). More in-depth answers regarding the POSIX philosophy may be interesting, too.
The base concept here is, that virtually every operation in a computer essentially comes down to moving data around. Data is read, transformed and written. Of course, depending on which hardware is origin of the data read or target of the data written, the real-world outcome is totally different.
Historically, popular devices for data storage (assume a hard-drive) were handled by the SCSI driver. That is why storage is commonly prefixed with sd
. You then want a logical "software" representation of the individual physical "hardware" device. You just number them, starting with a
. Concatenated, a hard-drive may be referred to as sda
.
Now you have a "file" which you can read data from (writing is analogous). If you read the first byte from /dev/sda
, you will actually read the byte which is actually sitting on the very beginning of that data storage device (block sizes ignored for the sake of simplicity). You can try this yourself by starting sudo hexdump -C /dev/sda | less
. Of course, most of the content will be gibberish to the naked eye.
However if you interpreted that gibberish so you know where a partition starts and mount that partition, a program (the filesystem driver) interprets the data for you and presents a nice tree-like structure with folders and files you can then read data from in return.
Fun fact: This also holds (to varying degrees) for other kinds of devices (character devices) like keyboards and mice (they "produce" data you can read): sudo hexdump -C /dev/input/mouse0
).
Or the main memory.
Or even the graphics memory (framebuffer): I occasionally enjoy switching to one of the virtual consoles (Ctrl+Alt+F1) and have my graphics card interpret and display random numbers via sudo dd if=/dev/urandom of=/dev/fb0 bs=1M count=1
edited 2 days ago
answered 2 days ago
HermannHermann
929515
929515
add a comment |
add a comment |
-devices, filesystems, linux
Welcome to U&L! Folders (directories) are files as well. Apart from that, your question is comprised of multiple questions which makes this too broad to answer. Please ask a single question at a time. Good luck.
– heemayl
2 days ago
thanks for replaying @heemayl . questions were spinning around my head that's why I posted all the questions at once . if I won't get any good answer then I definitely post the question in parts. thanks again . BTW I am from Bangladesh too
– sabbir
2 days ago
Great! Nice to see you here :)
– heemayl
2 days ago
What would the alternative be?
– Kusalananda
2 days ago
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
2 days ago