Linux 如何知道哪些进程打开TCP端口?
我使用的是Busybox发行版,没有iptables。我想了解哪些进程打开端口:8001和35292以杀死它们并关闭这些端口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
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,或者服务器故障(等等)。太好了!有了这个参数,我可以解决我的疑问。