我严重依赖查看netstat
输出
sudo netstat -peanut
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 0 27575 1902/docker-proxy
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 0 26977 1519/docker-proxy
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 0 15340 537/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 20953 925/nginx: master p
tcp 0 0 0.0.0.0:8181 0.0.0.0:* LISTEN 0 25191 1236/haproxy
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 101 17893 716/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 20941 921/sshd
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 0 25193 1236/haproxy
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 0 20954 925/nginx: master p
tcp 0 0 172.18.0.1:44638 172.18.0.2:27017 TIME_WAIT 0 0 -
tcp 0 0 172.18.0.1:44774 172.18.0.2:27017 ESTABLISHED 0 31237 1528/docker-proxy
tcp 0 0 172.18.0.1:39470 172.18.0.3:27017 ESTABLISHED 0 32005 1574/docker-proxy
这是另一颗宝石
netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1902/docker-proxy
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 1519/docker-proxy
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 537/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 925/nginx: master p
tcp 0 0 0.0.0.0:8181 0.0.0.0:* LISTEN 1236/haproxy
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 716/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 921/sshd
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN 1236/haproxy
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 925/nginx: master p
tcp6 0 0 :::27017 :::* LISTEN 1594/docker-proxy
tcp6 0 0 :::587 :::* LISTEN 1915/docker-proxy
然而netstat
据说被诸如ss
等工具所取代......有谁知道如何产生类似于上述现代方式的输出?
sudo ss -l -p -n
sudo ss -tnlp
我的尝试是否还不够丰富,netstat
并且 ss 格式不适合人类阅读
Debian/Ubuntu
答案1
第一个命令:
ss -tap
第二条命令
ss -tlp