How can non-root user monitor network traffic at command line?












0















I know that gnome-system-monitor can show me bandwidth even when opened by a non-root user. But tools like iftop, nethogs, etc. all seem to require root to work. How can I allow a regular user to do what gnome-system-monitor does? The application I'm going for is a script that outputs Mb/s up/down every n seconds, used for piping to a status line.










share|improve this question























  • Non-root cannot monitor network traffic. They can see system-generated totals though

    – qasdfdsaq
    Nov 9 '15 at 15:15
















0















I know that gnome-system-monitor can show me bandwidth even when opened by a non-root user. But tools like iftop, nethogs, etc. all seem to require root to work. How can I allow a regular user to do what gnome-system-monitor does? The application I'm going for is a script that outputs Mb/s up/down every n seconds, used for piping to a status line.










share|improve this question























  • Non-root cannot monitor network traffic. They can see system-generated totals though

    – qasdfdsaq
    Nov 9 '15 at 15:15














0












0








0








I know that gnome-system-monitor can show me bandwidth even when opened by a non-root user. But tools like iftop, nethogs, etc. all seem to require root to work. How can I allow a regular user to do what gnome-system-monitor does? The application I'm going for is a script that outputs Mb/s up/down every n seconds, used for piping to a status line.










share|improve this question














I know that gnome-system-monitor can show me bandwidth even when opened by a non-root user. But tools like iftop, nethogs, etc. all seem to require root to work. How can I allow a regular user to do what gnome-system-monitor does? The application I'm going for is a script that outputs Mb/s up/down every n seconds, used for piping to a status line.







linux bandwidth bash-scripting network-monitoring






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 '15 at 17:12









nullUsernullUser

3381622




3381622













  • Non-root cannot monitor network traffic. They can see system-generated totals though

    – qasdfdsaq
    Nov 9 '15 at 15:15



















  • Non-root cannot monitor network traffic. They can see system-generated totals though

    – qasdfdsaq
    Nov 9 '15 at 15:15

















Non-root cannot monitor network traffic. They can see system-generated totals though

– qasdfdsaq
Nov 9 '15 at 15:15





Non-root cannot monitor network traffic. They can see system-generated totals though

– qasdfdsaq
Nov 9 '15 at 15:15










3 Answers
3






active

oldest

votes


















4














The data you want is available for everyone, at /proc/net/dev. However, you’ll have to calculate bandwidth yourself, by taking the delta and the time between two values.



Keep in mind though, that these counters may overflow, depending on your system’s architecture and kernel version. Overflow may occur at 232-1 (reachable in a matter of seconds on Gigabit Ethernet) or 264-1 (virtually irrelevant).






share|improve this answer

































    1














    Dir /sys/class/net/${interface}/statistics/ has all you need.



    BASH script based on this: check_bandwidth.sh






    share|improve this answer































      0














      Let's assume you're talking about nethogs. We know that nethogs is owned by root if we do ls -l $(which nethogs).



      All we need to do now is change the SUID bit so that when nethogs is run, it will run with the permissions of its owner (i.e. root). Run:



      sudo chmod u+s $(which nethogs)



      And it should work.






      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        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%2fsuperuser.com%2fquestions%2f997416%2fhow-can-non-root-user-monitor-network-traffic-at-command-line%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









        4














        The data you want is available for everyone, at /proc/net/dev. However, you’ll have to calculate bandwidth yourself, by taking the delta and the time between two values.



        Keep in mind though, that these counters may overflow, depending on your system’s architecture and kernel version. Overflow may occur at 232-1 (reachable in a matter of seconds on Gigabit Ethernet) or 264-1 (virtually irrelevant).






        share|improve this answer






























          4














          The data you want is available for everyone, at /proc/net/dev. However, you’ll have to calculate bandwidth yourself, by taking the delta and the time between two values.



          Keep in mind though, that these counters may overflow, depending on your system’s architecture and kernel version. Overflow may occur at 232-1 (reachable in a matter of seconds on Gigabit Ethernet) or 264-1 (virtually irrelevant).






          share|improve this answer




























            4












            4








            4







            The data you want is available for everyone, at /proc/net/dev. However, you’ll have to calculate bandwidth yourself, by taking the delta and the time between two values.



            Keep in mind though, that these counters may overflow, depending on your system’s architecture and kernel version. Overflow may occur at 232-1 (reachable in a matter of seconds on Gigabit Ethernet) or 264-1 (virtually irrelevant).






            share|improve this answer















            The data you want is available for everyone, at /proc/net/dev. However, you’ll have to calculate bandwidth yourself, by taking the delta and the time between two values.



            Keep in mind though, that these counters may overflow, depending on your system’s architecture and kernel version. Overflow may occur at 232-1 (reachable in a matter of seconds on Gigabit Ethernet) or 264-1 (virtually irrelevant).







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 9 '15 at 15:24

























            answered Nov 7 '15 at 17:16









            Daniel BDaniel B

            33.5k76187




            33.5k76187

























                1














                Dir /sys/class/net/${interface}/statistics/ has all you need.



                BASH script based on this: check_bandwidth.sh






                share|improve this answer




























                  1














                  Dir /sys/class/net/${interface}/statistics/ has all you need.



                  BASH script based on this: check_bandwidth.sh






                  share|improve this answer


























                    1












                    1








                    1







                    Dir /sys/class/net/${interface}/statistics/ has all you need.



                    BASH script based on this: check_bandwidth.sh






                    share|improve this answer













                    Dir /sys/class/net/${interface}/statistics/ has all you need.



                    BASH script based on this: check_bandwidth.sh







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 9 '15 at 15:05









                    7171u7171u

                    1112




                    1112























                        0














                        Let's assume you're talking about nethogs. We know that nethogs is owned by root if we do ls -l $(which nethogs).



                        All we need to do now is change the SUID bit so that when nethogs is run, it will run with the permissions of its owner (i.e. root). Run:



                        sudo chmod u+s $(which nethogs)



                        And it should work.






                        share|improve this answer




























                          0














                          Let's assume you're talking about nethogs. We know that nethogs is owned by root if we do ls -l $(which nethogs).



                          All we need to do now is change the SUID bit so that when nethogs is run, it will run with the permissions of its owner (i.e. root). Run:



                          sudo chmod u+s $(which nethogs)



                          And it should work.






                          share|improve this answer


























                            0












                            0








                            0







                            Let's assume you're talking about nethogs. We know that nethogs is owned by root if we do ls -l $(which nethogs).



                            All we need to do now is change the SUID bit so that when nethogs is run, it will run with the permissions of its owner (i.e. root). Run:



                            sudo chmod u+s $(which nethogs)



                            And it should work.






                            share|improve this answer













                            Let's assume you're talking about nethogs. We know that nethogs is owned by root if we do ls -l $(which nethogs).



                            All we need to do now is change the SUID bit so that when nethogs is run, it will run with the permissions of its owner (i.e. root). Run:



                            sudo chmod u+s $(which nethogs)



                            And it should work.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 5 at 3:59









                            dualscytherdualscyther

                            1




                            1






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Super User!


                                • 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%2fsuperuser.com%2fquestions%2f997416%2fhow-can-non-root-user-monitor-network-traffic-at-command-line%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

                                Probability when a professor distributes a quiz and homework assignment to a class of n students.

                                Aardman Animations

                                Are they similar matrix