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

时间:2014-05-04 20:20:15

标签: 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      
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

1 个答案:

答案 0 :(得分:0)

来自man netstat

-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或服务器故障(以及其他)。

相关问题