ifconfig

ip

route -n

hostname(uname -n)

netstat (ESTABLISHED状态的为建立的状态,数量即表示网络连接数)

lsof 

 

面试题:已知一个端口为333,如何查看端口对应的是什么服务名?

方法1: lsof -i :333

# 例如:查看22端口的对应服务名
[root@oldboy share]# lsof -i :22 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sshd 1261 root 3u IPv4 9347 0t0 TCP *:ssh (LISTEN) sshd 1261 root 4u IPv6 9349 0t0 TCP *:ssh (LISTEN) sshd 5986 root 3r IPv4 32808 0t0 TCP 192.168.0.109:ssh->192.168.0.102:53902 (ESTABLISHED)

方法2: netstat -lntup| grep 22

[root@oldboy share]# netstat -lntup|grep 22
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1261/sshd           
tcp        0      0 :::22                       :::*                        LISTEN      1261/sshd   

 

posted on 2019-11-22 16:02  Zoe233  阅读(484)  评论(0编辑  收藏  举报