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










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















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













-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 yesterday









Rui F Ribeiro

41.7k1483141




41.7k1483141






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 yesterday









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

















  • 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










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 yesterday

























        answered yesterday









        HermannHermann

        929515




        929515













            Popular posts from this blog

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.