是否有类似顶部的工具可以实时显示进程和端口?

Lui*_*bia 2 linux port top process

我想“实时”监视端口以及使用它们的进程。有什么工具可以处理这个问题吗?我想象像顶部一样,但有一个列列出了进程正在使用的所有端口...或者端口、协议以及打开该端口或正在侦听的进程的列表。

这是针对基于 Linux 的操作系统。

Jos*_*ber 5

只是想问哪个操作系统,并注意到您进行了编辑以添加该操作系统。那你很幸运。在 BASH shell 中尝试一下这种快速而肮脏的单行代码(作为 root):

while true ; do output=$(netstat -anptu) ; clear ; echo "$output" ; sleep 2 ; done
Run Code Online (Sandbox Code Playgroud)

编辑:更简洁、有序的输出:

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
Run Code Online (Sandbox Code Playgroud)