1. 程式人生 > >Linux 網絡相關命令

Linux 網絡相關命令

www 監聽 roc TP and mman AD ces program

https://www.cnblogs.com/wangtao1993/p/6144183.html

Linux如何查看端口

lsof -i:端口號 用於查看某一端口的占用情況,比如查看8000端口使用情況,lsof -i:51606

1 lsof -i:51606
2 
3 COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
4 MotionPro 1582 mamp   15u  IPv4 611126      0t0  UDP localhost:51606 

可以看出 51606 被 MotionPro服務占用

netstat -tunlp | grep 端口號

1 netstat -tunlp |grep 51606
2 (Not all processes could be identified, non-owned process info
3  will not be shown, you would have to be root to see it all.)
4 udp        0      0 127.0.0.1:51606         0.0.0.0:*                           1582/MotionPro  
1 sudo netstat -utnlp
2 [sudo] password for ××××: 
3 Active Internet connections (only servers) 4 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 5 tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 1415/redis-server 1
1  netstat -utnlp 
2 Active Internet connections (only servers)
3 Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name 4 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 38/sshd 5 tcp 0 0 :::22 :::* LISTEN 38/sshd

netstat 各個參數含義:

  • -t (tcp) 僅顯示tcp相關選項
  • -u (udp)僅顯示udp相關選項
  • -n 拒絕顯示別名,能顯示數字的全部轉化為數字
  • -l 僅列出在Listen(監聽)的服務狀態
  • -p 顯示建立相關鏈接的程序名

traceroute

Linux 網絡相關命令