netstat可以查看linux系统中正在使用的服务和端口情况

netstat [-选项]

netstat各选项参数说明:
-a : 列出所有连接,服务监听,Socket信息
-c : 持续列出网络状态 #每隔一秒输出网络信息
-t : 显示TCP端口
-u : 显示UDP端口
-l : 列出当前监听服务,只显示监听端口
-p : 显示PID(进程号)和进程名称
-n : 直接使用ip地址,而不通过域名服务器(加速输出,因为不用进行比对查询)
-s : 显示网络工作信息统计表
-r : 显示路由表信息

常用:
netstat -a #列出所有端口 
netstat -at #列出所有tcp端口
netstat -anp
[lxm@localhost ~]$ netstat -anp | less
(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 0.0.0.0:58178               0.0.0.0:*                   LISTEN      -
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      -
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      -
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      -
tcp        0      0 10.21.9.82:17315            10.21.255.72:9988           ESTABLISHED -
tcp        0      0 10.21.9.82:22               10.11.111.145:50520         ESTABLISHED -
tcp        0      0 :::7070                     :::*                        LISTEN      227054/java
tcp        0      0 :::111                      :::*                        LISTEN      -
tcp        0      0 :::1528                     :::*                        LISTEN      227054/java
tcp        0      0 ::ffff:127.0.0.1:34790      ::ffff:127.0.0.1:1528       ESTABLISHED 227054/java
tcp        0      0 ::ffff:127.0.0.1:1528       ::ffff:127.0.0.1:34790      ESTABLISHED 227054/java
udp        0      0 127.0.0.1:766               0.0.0.0:*                               -
udp        0      0 10.21.9.82:123              0.0.0.0:*                               -
udp        0      0 127.0.0.1:123               0.0.0.0:*                               -
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               -
udp        0      0 :::111                      :::*                                    -
udp        0      0 fe80::439:44ff:fe00:2e4e:123 :::*                                    -
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node PID/Program name    Path
unix  10     [ ]         DGRAM                    10801  -                   /dev/log
unix  2      [ ACC ]     STREAM     LISTENING     11258  -                   /var/run/cups/cups.sock
unix  2      [ ACC ]     STREAM     LISTENING     10990  -                   /var/run/rpcbind.sock
unix  2      [ ACC ]     STREAM     LISTENING     7650   -                   @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     11926  -                   /var/run/abrt/abrt.socket
unix  2      [ ACC ]     STREAM     LISTENING     11358  -                   @/var/run/hald/dbus-b6ivIYqcZP
unix  2      [ ]         DGRAM                    11388  -                   @/org/freedesktop/hal/udev_event
unix  2      [ ]         DGRAM                    8215   -                   @/org/kernel/udev/udevd
unix  2      [ ACC ]     STREAM     LISTENING     11363  -                   @/var/run/hald/dbus-25Zkk4VrNe
unix  2      [ ACC ]     STREAM     LISTENING     12624  -                   /usr/local/sec_agent/secbase/sec_agent.unix

Proto :网络传输协议,主要为tcp和udp
Local Address :本地的ip:port
Foreign Address:远程主机的ip:port
State :连线状态,主要有监听( LISTEN )和建立(ESTABLISED)
PID :服务的进程号
Program name:服务名称

GitHub 加速计划 / li / linux-dash
6
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:3 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐