Linux 等效于 Solaris 中的 lsof -i
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20670400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Equivalent lsof -i in Solaris
提问by Alberto
I have a fast question. I want to know what is the losf -i
equivalent command in a Solaris system.
我有一个快速的问题。我想知道losf -i
Solaris 系统中的等效命令是什么。
I only want to show the files with network connection.
我只想显示具有网络连接的文件。
Thank you!!
谢谢!!
采纳答案by jlliagre
Here is a shell script that list all processes having open TCP or UDP ports on Solaris, you can limit it to a given port number by passing it as an argument:
这是一个 shell 脚本,它列出了 Solaris 上所有具有开放 TCP 或 UDP 端口的进程,您可以通过将其作为参数传递来将其限制为给定的端口号:
pfiles /proc/* 2>/dev/null | nawk -v port= '
/^[0-9]/ { cmd=; type="unknown"; continue }
== "SOCK_STREAM" { type="tcp" }
== "SOCK_DGRAM" { type="udp" }
~ "AF_INET" { if((port!="")&&(!=port)) continue;
if(cmd!="") { printf("%s\n",cmd); cmd="" }
printf(" %s:%s/%s\n",,,type); }'
Note: As documented in the warning section of the pfiles
manual page, it is not recommended to run this command on a heavily loaded production system with a time sensitive process running as deadlocks or crashes might happen.
注意:如pfiles
手册页的警告部分所述,不建议在负载重的生产系统上运行此命令,因为可能会发生死锁或崩溃。
Note #2: The previous warning doesn't apply to the last update of Solaris (Oracle Solaris 11.4) because pfiles
no more suspend the monitored process(es). It now just uses ad hoc /proc pseudo files.
注意 #2:之前的警告不适用于 Solaris (Oracle Solaris 11.4) 的最后一次更新,因为pfiles
不再暂停受监视的进程。它现在只使用临时 /proc 伪文件。
回答by Tharanga Abeyseela
you can try pfiles,fuser. you can install lsof on solaris.
你可以试试pfiles,fuser。你可以在solaris上安装lsof。
http://andriigrytsenko.net/2010/08/lsof-installation-on-solaris-10/
http://andriigrytsenko.net/2010/08/lsof-installation-on-solaris-10/
回答by peterh
As of Solaris 11.2 this type of information is now available directly in the netstatcommand (-u
option) so you don't have to use the pfiles
hack for the purpose or use the lsof
tool. Personally I've always wondered why this information could not be part of the netstat
output so glad to see that'll finally be the case.
从 Solaris 11.2 开始,这种类型的信息现在可以直接在netstat命令(-u
选项)中使用,因此您不必pfiles
为此目的使用 hack 或使用该lsof
工具。就我个人而言,我一直想知道为什么这些信息不能成为netstat
输出的一部分,很高兴看到最终会如此。
There's a nice blog from Oracle on the topic.
(caveat: at the time of writing v11.2 is in beta but fully disclosed as to the contents / new features)
(警告:在撰写本文时,v11.2 处于测试阶段,但已完全披露内容/新功能)