Log Files - difference between using sudo or not












0















You start by going into the logs with cd /var/log



Then you want to look at the kern.log



I did this firstly by using sudo less kern.log, then less kern.log



Both outputs were the same.



So what exactly is the difference between using sudo for the command, or leaving it without it?










share|improve this question



























    0















    You start by going into the logs with cd /var/log



    Then you want to look at the kern.log



    I did this firstly by using sudo less kern.log, then less kern.log



    Both outputs were the same.



    So what exactly is the difference between using sudo for the command, or leaving it without it?










    share|improve this question

























      0












      0








      0








      You start by going into the logs with cd /var/log



      Then you want to look at the kern.log



      I did this firstly by using sudo less kern.log, then less kern.log



      Both outputs were the same.



      So what exactly is the difference between using sudo for the command, or leaving it without it?










      share|improve this question














      You start by going into the logs with cd /var/log



      Then you want to look at the kern.log



      I did this firstly by using sudo less kern.log, then less kern.log



      Both outputs were the same.



      So what exactly is the difference between using sudo for the command, or leaving it without it?







      command-line log






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 13:07









      Felix RFelix R

      113




      113






















          3 Answers
          3






          active

          oldest

          votes


















          3














          The sudo lets you access whether it be to read (as in your case) or to write to folders and files irrespective of the ownership status or permission status of those folders or files.



          In this case of the /var/log folder these files usually don't need you to be the root user to read from them hence log files are accessible for most users at least the read part. But we have certain processes that will produce log entries that only the system user (that created those log) or the root user can read from such files, examples include auth.log, mail.log, php7.2-fpm.log etc. These I have picked from my own /var/log folder.



          Run the command ls -l /var/log to see those files and the permissions that are associated with them, including their ownerships. From there you can decern when you will need to use sudo and when you will not.






          share|improve this answer

































            2














            For succesful use of the less-command you will need read-permissions. Let's check the permissions of the file:



            ~$ ll /var/log/kern.log
            -rw-r----- 1 syslog adm 1366232 Jan 3 19:50 /var/log/kern.log


            The file is owned by the user syslog who has read and write permissions. The file is also associated with the group adm which has read permission. As you were able to read the file as a regular (non-root) user, you are obviously a member of the adm-group. You may check it with the groups-command.



            ~$ groups
            mook adm cdrom sudo audio dip plugdev lpadmin sambashare





            share|improve this answer































              0














              sudo command allows you run commands with security privileges of another user, by default as the superuser or root user. you can not run the init command as normal user until you use sudo, like that there are lots of other administrative commands and operation where you must use sudo to perform those operations, there are lot of security reason why we are using sudo.






              share|improve this answer























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                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',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1106574%2flog-files-difference-between-using-sudo-or-not%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                3














                The sudo lets you access whether it be to read (as in your case) or to write to folders and files irrespective of the ownership status or permission status of those folders or files.



                In this case of the /var/log folder these files usually don't need you to be the root user to read from them hence log files are accessible for most users at least the read part. But we have certain processes that will produce log entries that only the system user (that created those log) or the root user can read from such files, examples include auth.log, mail.log, php7.2-fpm.log etc. These I have picked from my own /var/log folder.



                Run the command ls -l /var/log to see those files and the permissions that are associated with them, including their ownerships. From there you can decern when you will need to use sudo and when you will not.






                share|improve this answer






























                  3














                  The sudo lets you access whether it be to read (as in your case) or to write to folders and files irrespective of the ownership status or permission status of those folders or files.



                  In this case of the /var/log folder these files usually don't need you to be the root user to read from them hence log files are accessible for most users at least the read part. But we have certain processes that will produce log entries that only the system user (that created those log) or the root user can read from such files, examples include auth.log, mail.log, php7.2-fpm.log etc. These I have picked from my own /var/log folder.



                  Run the command ls -l /var/log to see those files and the permissions that are associated with them, including their ownerships. From there you can decern when you will need to use sudo and when you will not.






                  share|improve this answer




























                    3












                    3








                    3







                    The sudo lets you access whether it be to read (as in your case) or to write to folders and files irrespective of the ownership status or permission status of those folders or files.



                    In this case of the /var/log folder these files usually don't need you to be the root user to read from them hence log files are accessible for most users at least the read part. But we have certain processes that will produce log entries that only the system user (that created those log) or the root user can read from such files, examples include auth.log, mail.log, php7.2-fpm.log etc. These I have picked from my own /var/log folder.



                    Run the command ls -l /var/log to see those files and the permissions that are associated with them, including their ownerships. From there you can decern when you will need to use sudo and when you will not.






                    share|improve this answer















                    The sudo lets you access whether it be to read (as in your case) or to write to folders and files irrespective of the ownership status or permission status of those folders or files.



                    In this case of the /var/log folder these files usually don't need you to be the root user to read from them hence log files are accessible for most users at least the read part. But we have certain processes that will produce log entries that only the system user (that created those log) or the root user can read from such files, examples include auth.log, mail.log, php7.2-fpm.log etc. These I have picked from my own /var/log folder.



                    Run the command ls -l /var/log to see those files and the permissions that are associated with them, including their ownerships. From there you can decern when you will need to use sudo and when you will not.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jan 3 at 13:40

























                    answered Jan 3 at 13:16









                    George UdosenGeorge Udosen

                    20.6k94467




                    20.6k94467

























                        2














                        For succesful use of the less-command you will need read-permissions. Let's check the permissions of the file:



                        ~$ ll /var/log/kern.log
                        -rw-r----- 1 syslog adm 1366232 Jan 3 19:50 /var/log/kern.log


                        The file is owned by the user syslog who has read and write permissions. The file is also associated with the group adm which has read permission. As you were able to read the file as a regular (non-root) user, you are obviously a member of the adm-group. You may check it with the groups-command.



                        ~$ groups
                        mook adm cdrom sudo audio dip plugdev lpadmin sambashare





                        share|improve this answer




























                          2














                          For succesful use of the less-command you will need read-permissions. Let's check the permissions of the file:



                          ~$ ll /var/log/kern.log
                          -rw-r----- 1 syslog adm 1366232 Jan 3 19:50 /var/log/kern.log


                          The file is owned by the user syslog who has read and write permissions. The file is also associated with the group adm which has read permission. As you were able to read the file as a regular (non-root) user, you are obviously a member of the adm-group. You may check it with the groups-command.



                          ~$ groups
                          mook adm cdrom sudo audio dip plugdev lpadmin sambashare





                          share|improve this answer


























                            2












                            2








                            2







                            For succesful use of the less-command you will need read-permissions. Let's check the permissions of the file:



                            ~$ ll /var/log/kern.log
                            -rw-r----- 1 syslog adm 1366232 Jan 3 19:50 /var/log/kern.log


                            The file is owned by the user syslog who has read and write permissions. The file is also associated with the group adm which has read permission. As you were able to read the file as a regular (non-root) user, you are obviously a member of the adm-group. You may check it with the groups-command.



                            ~$ groups
                            mook adm cdrom sudo audio dip plugdev lpadmin sambashare





                            share|improve this answer













                            For succesful use of the less-command you will need read-permissions. Let's check the permissions of the file:



                            ~$ ll /var/log/kern.log
                            -rw-r----- 1 syslog adm 1366232 Jan 3 19:50 /var/log/kern.log


                            The file is owned by the user syslog who has read and write permissions. The file is also associated with the group adm which has read permission. As you were able to read the file as a regular (non-root) user, you are obviously a member of the adm-group. You may check it with the groups-command.



                            ~$ groups
                            mook adm cdrom sudo audio dip plugdev lpadmin sambashare






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 3 at 13:27









                            mook765mook765

                            3,96421330




                            3,96421330























                                0














                                sudo command allows you run commands with security privileges of another user, by default as the superuser or root user. you can not run the init command as normal user until you use sudo, like that there are lots of other administrative commands and operation where you must use sudo to perform those operations, there are lot of security reason why we are using sudo.






                                share|improve this answer




























                                  0














                                  sudo command allows you run commands with security privileges of another user, by default as the superuser or root user. you can not run the init command as normal user until you use sudo, like that there are lots of other administrative commands and operation where you must use sudo to perform those operations, there are lot of security reason why we are using sudo.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    sudo command allows you run commands with security privileges of another user, by default as the superuser or root user. you can not run the init command as normal user until you use sudo, like that there are lots of other administrative commands and operation where you must use sudo to perform those operations, there are lot of security reason why we are using sudo.






                                    share|improve this answer













                                    sudo command allows you run commands with security privileges of another user, by default as the superuser or root user. you can not run the init command as normal user until you use sudo, like that there are lots of other administrative commands and operation where you must use sudo to perform those operations, there are lot of security reason why we are using sudo.







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Jan 3 at 13:33









                                    souravsourav

                                    791313




                                    791313






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1106574%2flog-files-difference-between-using-sudo-or-not%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Ellipse (mathématiques)

                                        Quarter-circle Tiles

                                        Mont Emei