[[email protected] ~]# netstat [選項]
選項:
[[email protected] ~]# netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0:::11211 :::* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
udp 0 0 0.0.0.0:11211 0.0.0.0:*
udp 0 0:::11211 :::*
#協定接收佇列傳送佇列本機的 IP 地址及埠號 遠端主機的 IP 地址及埠號 狀態
[[email protected] ~]# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2359/mysqld
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 1563/memcached
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1490/sshd
tcp 0 0 :::11211 :::* LISTEN 1563/memcached
tcp 0 0 :::80 :::* LISTEN 21025/httpd
tcp 0 0 :::22 :::*
LISTEN 1490/sshd
udp 0 0 0.0.0.0:11211 0.0.0.0:* 1563/memcached
udp 0 0:::11211 :::* 1563/memcached
#比之前的命令多了一個"-p"選項,結果多了可以知道是哪個程式佔用了埠
[[email protected] ~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN
tcp 0 0 117.79.130.170:80 78.46.174.55:58815 SYN_RECV
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 117.79.130.170:22 124.205.129.99:10379 ESTABLISHED
tcp 0 0 117.79.130.170:22 124.205.129.99:11811 ESTABLISHED
...省略部分內容...
udp 0 0 0.0.0.0:11211 0.0.0.0:*
udp 0 0:::11211 :::*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ACC] STREAM LISTENING 9761 @/var/run/hald/dbus-fr41WkQn1C
…省略部分內容...