Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, we'd like to see:

PROCESS       IF       TX       RX       FILE(regular) R/W
prog1         eth0     200kB/s  12kB/s   --            --
              wlan0    12kB/s   100kB/s  --            --
              --       --       --       file1         R
              --       --       --       file2         R
              --       --       --       file3         W
prog2         eth0     0kB/s    200kB/s  --            --
              --       --       --       file4         W
              --       --       --       file5         W

Is this possible? nethogs only shows the TX/RX, while lsof only shows the file accesses.

I'm currently doing a 2-step process like so:

sudo nethogs
sudo lsof -a -d 1-999 -c hogging_program /

Is there a better way?

share|improve this question
up vote 6 down vote accepted

I believe what you're trying to accomplish is probably best (and AFAIK only) possible combining multiple commands as you're currently doing. With some clever shell scripting and piped data, you could get the output you're looking for.

You seem to be up against some tenants of 'The UNIX Philosophy:'

  • Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new features.
  • Expect the output of every program to become the input to another, as yet unknown, program. Don't clutter output with extraneous information.

This is particularly evident in programs that output text, like lsof. Doug McIlroy summarized his earlier statement years later:

Write programs that do one thing and do it well. Write programs to work together. Write programs to handle text streams, because that is a universal interface.

While it may not help you get the formatted output you're looking for, The Art of UNIX Programming is a good read, and where I found sources for those quotes.

share|improve this answer
This does not provide an answer to the question. – cat Jun 21 at 20:27
Is this possible? -- I believe what you're trying to accomplish is probably best (and as far as I know only) possible combining multiple commands as your currently doing. -- is there a better way? I believe what you're trying is probably best and only possible convincing multiple commands... wiith some clever shell scripting and piped data, you could get the output [formatted the way] you're looking for. -- what question did I miss? might be better answered with a mention of piped shell scripts, but your helpful feedback didn't mention that :p is the proper answer a working script? – overprescribed Jun 22 at 0:45

atop goes some way to giving you what you want, although it wouldn't be as specific as breaking down I/O by filehandle. To get full networking statistics you have to apply a kernel patch.

share|improve this answer

Try iftop for network and pidstat from sysstat.

Both are probably an easy install (apt-get, etc) for the distribution of your choice.

share|improve this answer

iptraf can be very usefull and finding bandwidth hogs.

share|improve this answer
Adding more info/explanation will make your answer better. – mtk Mar 18 '13 at 13:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.