Netstat
如何獲取連接到外部ip的pid號?
一些程序從我的本地 ip 111.111.111.111 與 130.239.18.176:80 連接,如何獲取 pid 號?
netstat -np (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 111.111.111.111:46243 52.89.80.240:443 TIME_WAIT - tcp 0 1 111.111.111.111:36553 173.239.79.210:443 SYN_SENT 2630/firefox-esr tcp 0 0 111.111.111.111:48470 130.239.18.176:80 ESTABLISHED - tcp 0 1 111.111.111.111:36552 173.239.79.210:443 SYN_SENT 2630/firefox-esr tcp 0 1 111.111.111.111:34202 74.125.204.101:80 SYN_SENT 2630/firefox-esr tcp 0 0 111.111.111.111:52243 203.208.48.79:443 ESTABLISHED 2630/firefox-esr tcp 0 1 111.111.111.111:46521 74.125.203.93:443 SYN_SENT 2630/firefox-esr tcp 0 1 111.111.111.111:34200 74.125.204.101:80 SYN_SENT 2630/firefox-esr tcp 0 0 111.111.111.111:48424 130.239.18.176:80 ESTABLISHED - tcp 0 0 111.111.111.111:46238 52.89.80.240:443 TIME_WAIT - tcp 0 1 111.111.111.111:46523 74.125.203.93:443 SYN_SENT 2630/firefox-esr tcp 0 0 111.111.111.111:34204 74.125.204.101:80 TIME_WAIT - tcp 0 0 111.111.111.111:33700 104.24.98.177:443 ESTABLISHED 2630/firefox-esr tcp 0 1 111.111.111.111:34206 74.125.204.101:80 SYN_SENT 2630/firefox-esr tcp 0 0 127.0.0.1:49941 127.0.0.1:80 ESTABLISHED 2630/firefox-esr
netstat
輸出很好地解釋了它:(並非所有程序都可以辨識,不會顯示非擁有程序資訊,您必須是 root 才能看到所有內容。)
只需以root身份執行它(例如
sudo netstat -np
)