Linux – top like tool that shows processes and ports, live

linuxportprocesstop

I'd like to be monitoring ports in "realtime" and the processes that use them. Is there any tool that can handle that?
I imagine somethinkg like top, but with a column that lists all ports the process is using… or a list of ports, protocol, and the process that has that port open or is listenting to.

This is for Linux based OS.

Best Answer

Was just going to ask which OS and noticed that you edited to add that. You're in luck then. Try this quick and dirty one-liner (as root) in a BASH shell:

while true ; do output=$(netstat -anptu) ; clear ; echo "$output" ; sleep 2 ; done

edit: More concise, ordered output:

while true ; do output=$( (netstat -anpt | awk '{ print $1" "$4" "$7" "$6 }' | tail -n +3 ; netstat -anpu | awk '{ print $1" "$4" "$6 }' | tail -n +3 ) | egrep '[0-9]\/' | sort | uniq) ; clear ; date ; echo "$output" ; sleep 2 ; done