How can non-root user monitor network traffic at command line?
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
add a comment |
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
Non-root cannot monitor network traffic. They can see system-generated totals though
– qasdfdsaq
Nov 9 '15 at 15:15
add a comment |
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
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
linux bandwidth bash-scripting network-monitoring
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
add a comment |
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
add a comment |
3 Answers
3
active
oldest
votes
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).
add a comment |
Dir /sys/class/net/${interface}/statistics/
has all you need.
BASH script based on this: check_bandwidth.sh
add a comment |
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.
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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).
add a comment |
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).
add a comment |
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).
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).
edited Nov 9 '15 at 15:24
answered Nov 7 '15 at 17:16
Daniel BDaniel B
33.5k76187
33.5k76187
add a comment |
add a comment |
Dir /sys/class/net/${interface}/statistics/
has all you need.
BASH script based on this: check_bandwidth.sh
add a comment |
Dir /sys/class/net/${interface}/statistics/
has all you need.
BASH script based on this: check_bandwidth.sh
add a comment |
Dir /sys/class/net/${interface}/statistics/
has all you need.
BASH script based on this: check_bandwidth.sh
Dir /sys/class/net/${interface}/statistics/
has all you need.
BASH script based on this: check_bandwidth.sh
answered Nov 9 '15 at 15:05
7171u7171u
1112
1112
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Jan 5 at 3:59
dualscytherdualscyther
1
1
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Non-root cannot monitor network traffic. They can see system-generated totals though
– qasdfdsaq
Nov 9 '15 at 15:15