Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何知道哪些进程打开TCP端口?_Linux_Netstat - Fatal编程技术网

Linux 如何知道哪些进程打开TCP端口?

Linux 如何知道哪些进程打开TCP端口?,linux,netstat,Linux,Netstat,我使用的是Busybox发行版,没有iptables。我想了解哪些进程打开端口:8001和35292以杀死它们并关闭这些端口 root@(none):/proc/1709/net# netstat -a | grep LISTEN netstat: /proc/net/tcp6: No such file or directory tcp 0 0 (null):8001 (null):* LISTEN tc

我使用的是Busybox发行版,没有iptables。我想了解哪些进程打开端口:8001和35292以杀死它们并关闭这些端口

root@(none):/proc/1709/net# netstat -a | grep LISTEN
netstat: /proc/net/tcp6: No such file or directory
tcp        0      0 (null):8001             (null):*                LISTEN      
tcp        0      0 (null):rmiregistry      (null):*                LISTEN      
tcp        0      0 (null):ssh              (null):*                LISTEN      
tcp        0      0 (null):35292            (null):*                LISTEN
非常感谢

用参数-p解决疑问:

root@(none):~# netstat -a -p
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 (null):8001             (null):*                LISTEN      1527/java
tcp        0      0 (null):8002             (null):*                LISTEN      1527/java
tcp        0      0 (null):56618            (null):*                LISTEN      1527/java
tcp        0      0 (null):rmiregistry      (null):*                LISTEN      1527/java
tcp        0      0 (null):ssh              (null):*                LISTEN      1181/dropbear
tcp        0      0 (null):telnet           (null):*                LISTEN      1166/telnetd
tcp        0      0 (null):ssh              (null):55960            ESTABLISHED 1549/dropbear

mannetstat

-p, --program
Show the PID and name of the program to which each socket belongs.
通过添加
-p
选项,您将获得监听程序的PID。这足以在之后使用
ps

ps -ef | grep [your-pid]

但不确定您的问题是否是特定于编程的。我建议您使用Unix和Linux,或者服务器故障(等等)。

太好了!有了这个参数,我可以解决我的疑问。