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










-1















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?










share|improve this question









New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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















-1















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?










share|improve this question









New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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













-1












-1








-1








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?










share|improve this question









New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago









Rui F Ribeiro

41.7k1483142




41.7k1483142






New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









sabbirsabbir

12




12




New contributor




sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






sabbir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




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

















  • 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










1 Answer
1






active

oldest

votes


















4














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






share|improve this answer































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    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






    share|improve this answer





























      4














      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






      share|improve this answer



























        4












        4








        4







        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






        share|improve this answer















        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







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered 2 days ago









        HermannHermann

        929515




        929515













            -devices, filesystems, linux

            Popular posts from this blog

            Frič See also Navigation menuinternal link

            Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant

            fontconfig warning: “/etc/fonts/fonts.conf”, line 100: unknown “element blank” The 2019 Stack Overflow Developer Survey Results Are In“tar: unrecognized option --warning” during 'apt-get install'How to fix Fontconfig errorHow do I figure out which font file is chosen for a system generic font alias?Why are some apt-get-installed fonts being ignored by fc-list, xfontsel, etc?Reload settings in /etc/fonts/conf.dTaking 30 seconds longer to boot after upgrade from jessie to stretchHow to match multiple font names with a single <match> element?Adding a custom font to fontconfigRemoving fonts from fontconfig <match> resultsBroken fonts after upgrading Firefox ESR to latest Firefox