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
How will losing mobility of one hand affect my career as a programmer?
How do I implement a file system driver driver in Linux?
Can I use my Chinese passport to enter China after I acquired another citizenship?
Diode in opposite direction?
Greatest common substring
Is possible to search in vim history?
How do I repair my stair bannister?
Is a model fitted to data or is data fitted to a model?
My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?
Translation of Scottish 16th century church stained glass
How must one send away the mother bird?
We have a love-hate relationship
Is it possible to have a strip of cold climate in the middle of a planet?
Should I stop contributing to retirement accounts?
Is it possible to use .desktop files to open local pdf files on specific pages with a browser?
Greco-Roman egalitarianism
Does the Mind Blank spell prevent the target from being frightened?
Is there a conventional notation or name for the slip angle?
Engineer refusing to file/disclose patents
What major Native American tribes were around Santa Fe during the late 1850s?
What is this type of notehead called?
Some numbers are more equivalent than others
Flux received by a negative charge
What linear sensor for a keyboard?
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 2 hours ago
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 2 hours ago
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
yesterday
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
yesterday
Great! Nice to see you here :)
– heemayl
yesterday
What would the alternative be?
– Kusalananda
yesterday
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
yesterday
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 yesterday
Rui F Ribeiro
41.7k1483141
41.7k1483141
New contributor
asked yesterday
sabbirsabbir
12
12
New contributor
New contributor
put on hold as too broad by heemayl, Kusalananda, Stephen Harris, jimmij, Jeff Schaller 2 hours ago
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 2 hours ago
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
yesterday
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
yesterday
Great! Nice to see you here :)
– heemayl
yesterday
What would the alternative be?
– Kusalananda
yesterday
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
yesterday
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
yesterday
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
yesterday
Great! Nice to see you here :)
– heemayl
yesterday
What would the alternative be?
– Kusalananda
yesterday
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
yesterday
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
yesterday
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
yesterday
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
yesterday
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
yesterday
Great! Nice to see you here :)
– heemayl
yesterday
Great! Nice to see you here :)
– heemayl
yesterday
What would the alternative be?
– Kusalananda
yesterday
What would the alternative be?
– Kusalananda
yesterday
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
yesterday
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
yesterday
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 yesterday
answered yesterday
HermannHermann
929515
929515
add a comment |
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
yesterday
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
yesterday
Great! Nice to see you here :)
– heemayl
yesterday
What would the alternative be?
– Kusalananda
yesterday
This is rather broad, but see also e.g. A layman's explanation for “Everything is a file” — what differs from Windows?
– ilkkachu
yesterday