[命令] Linux 命令 nestat (显示本地端口,以及其 PID 信息等)

案例一

$ netstat -ntulap
(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 (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:7001            0.0.0.0:*               LISTEN      1250/nxnode.bin     
tcp        0      0 127.0.0.1:25001         0.0.0.0:*               LISTEN      1345/nxrunner.bin   
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:3001          0.0.0.0:*               LISTEN      1316/pipewire
......


补充:
1) -n 不解析名称
2) -t 显示 tcp 端口
3) -u 显示 udp 端口
4) -l 显示服务器接口
5) -a 显示所有接口
6) -p 显示 PID 或者程序名称的接口

案例二

mingyuzhu@mingyuzhu:~$ netstat -W -neopa
(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 (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name     Timer
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      991        6431       -                    off (0.00/0/0)
tcp        0      0 0.0.0.0:7001            0.0.0.0:*               LISTEN      1001       11218      1250/nxnode.bin      off (0.00/0/0)
tcp        0      0 127.0.0.1:25001         0.0.0.0:*               LISTEN      1001       11498      1345/nxrunner.bin    off (0.00/0/0)
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      0          6018433    -                    off (0.00/0/0)
tcp        0      0 127.0.0.1:3001          0.0.0.0:*               LISTEN      1001       12293      1316/pipewire        off (0.00/0/0)
tcp        0      0 0.0.0.0:4000            0.0.0.0:*               LISTEN      121        11121      -                    off (0.00/0/0)
tcp        0      0 127.0.0.1:26001         0.0.0.0:*               LISTEN      1001       11426      1250/nxnode.bin      off (0.00/0/0)
tcp        0      0 127.0.0.1:26002         0.0.0.0:*               LISTEN      1001       6513629    1065010/nxnode.bin   off (0.00/0/0)
......


补充:
1) -W 不缩写 IP 地址
2) -n 不解析名称
3) -e 显示更多的信息
4) -o 显示计时器
5) -p 显示 PID 或者程序名称的接口
6) -a 显示所有接