netstat 查看连接的时候打印进程名

这个本来是个很基本的需求啊,搜了一下,stackover flow 上面有讨论,在这里,http://stackoverflow.com/quest…

Try

ps -p $(lsof -ti tcp:80) o comm=,pid=
or

netstat -tlnp | awk ‘/:80 */ {split($NF,a,”/”); print a[2],a[1]}’

好麻烦,而且跑不了,后来发现加一个 -p 参数就可以了。。

netstat -p

不过需要 root 权限

Leave a Reply

Your email address will not be published. Required fields are marked *