What is file-like objects in linux?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












Linux Philosophy



Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.



Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.







share|improve this question
























    up vote
    0
    down vote

    favorite












    Linux Philosophy



    Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.



    Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.







    share|improve this question






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Linux Philosophy



      Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.



      Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.







      share|improve this question












      Linux Philosophy



      Linux borrows heavily from the UNIX operating system because it was written to be a free and open source version of UNIX. Files are stored in a hierarchical filesystem, with the top node of the system being root or simply "/". Whenever possible, Linux makes its components available via files or objects that look like files. Processes, devices, and network sockets are all represented by file-like objects, and can often be worked with using the same utilities used for regular files.



      Plz explain me in details what the line "Whenever possible, Linux makes its components available via files or objects that look like files" and what is "file-like objects" with an appropriate example.









      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 13 at 9:46









      coding_ninza

      33




      33




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.



          Processes:
          Each process has its folder /proc/$PPID/, where $PPID is the process id. You can find the command line for the process in /proc/$PPID/cmdline, for example.



          Devices:
          Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda and the first partition as /dev/sda1. So if you read from /dev/sda you are actually reading the raw data on the disk. This can be useful when making an image.



          Network sockets:
          bash uses /dev/tcp/$host/$port to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp



          Others:
          Standard input is also a file and you can find it in /dev/stdin, similar for standard output. You can read from the file /dev/zero to get zeros and from /dev/random to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.



          The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416778%2fwhat-is-file-like-objects-in-linux%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.



            Processes:
            Each process has its folder /proc/$PPID/, where $PPID is the process id. You can find the command line for the process in /proc/$PPID/cmdline, for example.



            Devices:
            Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda and the first partition as /dev/sda1. So if you read from /dev/sda you are actually reading the raw data on the disk. This can be useful when making an image.



            Network sockets:
            bash uses /dev/tcp/$host/$port to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp



            Others:
            Standard input is also a file and you can find it in /dev/stdin, similar for standard output. You can read from the file /dev/zero to get zeros and from /dev/random to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.



            The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.






            share|improve this answer


























              up vote
              4
              down vote



              accepted










              They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.



              Processes:
              Each process has its folder /proc/$PPID/, where $PPID is the process id. You can find the command line for the process in /proc/$PPID/cmdline, for example.



              Devices:
              Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda and the first partition as /dev/sda1. So if you read from /dev/sda you are actually reading the raw data on the disk. This can be useful when making an image.



              Network sockets:
              bash uses /dev/tcp/$host/$port to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp



              Others:
              Standard input is also a file and you can find it in /dev/stdin, similar for standard output. You can read from the file /dev/zero to get zeros and from /dev/random to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.



              The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.






              share|improve this answer
























                up vote
                4
                down vote



                accepted







                up vote
                4
                down vote



                accepted






                They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.



                Processes:
                Each process has its folder /proc/$PPID/, where $PPID is the process id. You can find the command line for the process in /proc/$PPID/cmdline, for example.



                Devices:
                Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda and the first partition as /dev/sda1. So if you read from /dev/sda you are actually reading the raw data on the disk. This can be useful when making an image.



                Network sockets:
                bash uses /dev/tcp/$host/$port to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp



                Others:
                Standard input is also a file and you can find it in /dev/stdin, similar for standard output. You can read from the file /dev/zero to get zeros and from /dev/random to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.



                The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.






                share|improve this answer














                They are stated in the paragraph. Processes, devices, and network sockets (and others). These are objects managed by the kernel but appear as items in the file system and you can access them through specific paths. Their behavior also resemble regular files in many aspects. For example, you can read from and write to a device file (see below) just as you do with regular files.



                Processes:
                Each process has its folder /proc/$PPID/, where $PPID is the process id. You can find the command line for the process in /proc/$PPID/cmdline, for example.



                Devices:
                Devices appear as device files. For example, if your hard disk is connected to a SCSI controller, you are likely to find it at /dev/sda and the first partition as /dev/sda1. So if you read from /dev/sda you are actually reading the raw data on the disk. This can be useful when making an image.



                Network sockets:
                bash uses /dev/tcp/$host/$port to identify TCP ports and alike for UDP. In general one can find information about sockets in /proc/net/tcp,udp



                Others:
                Standard input is also a file and you can find it in /dev/stdin, similar for standard output. You can read from the file /dev/zero to get zeros and from /dev/random to get really high-quality random number (although very slowly). Pipe is frequently used in the shell and you can also create a named pipe. There are many more.



                The answer above is based on Ubuntu LTS 16.04, other Linux/Unix versions may have different ways of indexing these objects.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 13 at 10:30

























                answered Jan 13 at 10:16









                Weijun Zhou

                1,434119




                1,434119






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f416778%2fwhat-is-file-like-objects-in-linux%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay