經過PID查看端口號:netstat -anop|grep pid
——其中的statusjava
ESTABLISHED:已經創建鏈接,正在進行數據交換,接收對方發來的數據 LISTEN:偵聽來自遠方的TCP鏈接請求,表示端口正在開放,能夠提供服務 SYN_SENT:發送鏈接請求等待匹配請求 FIN_WAIT_1:等待遠程TCP鏈接中斷的請求,或對先前中斷請求的確認 FIN_WAIT_2:從遠程TCP等待鏈接中斷請求 CLOSE_WAIT:等待從本地用戶發來的鏈接中斷請求 CLOSING:等待遠程TCP鏈接中斷的確認,表示端口認爲或防火牆關閉或服務被關停 LAST_ACK:等待原來發向遠程TCP鏈接中斷請求的確認 TIME_WAIT:正在等待鏈接 CLOSED:沒有任何鏈接
如:tcp
[lenovo@supervisor ~]$ netstat -anop|grep 38670 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) status tcp 0 0 :::6707 :::* LISTEN 38670/java off (0.00/0/0) tcp 0 0 ::ffff:192.168.0.219:53900 ::ffff:192.168.0.65:3306 ESTABLISHED 38670/java keepalive (3281.61/0/0) tcp 0 0 ::ffff:192.168.0.219:53901 ::ffff:192.168.0.65:3306 ESTABLISHED 38670/java keepalive (3281.63/0/0) tcp 0 0 ::ffff:192.168.0.219:43923 ::ffff:192.168.0.216:2181 ESTABLISHED 38670/java off (0.00/0/0) unix 2 [ ] STREAM CONNECTED 9828854 38670/java unix 2 [ ] STREAM CONNECTED 9828818 38670/java
lsof -p PID //查看進程pid打開的文件描述符,(通常狀況下,一個進程能夠打開的文件描述符的個數不超過1024)ide