Linux命令之netstat

Linux命令之netstat

学习netstat命令

查看帮助文档

**netstat -h**
[root@wangjibin01ecs ~]# netstat -h
    -r, --route              display routing table
    -I, --interfaces=<Iface> display interface table for <Iface>
    -i, --interfaces         display interface table
    -g, --groups             display multicast group memberships
    -s, --statistics         display networking statistics (like SNMP)
    -M, --masquerade         display masqueraded connections
    -v, --verbose            be verbose
    -W, --wide               don't truncate IP addresses
    -n, --numeric            don't resolve names
    --numeric-hosts          don't resolve host names
    --numeric-ports          don't resolve port names
    --numeric-users          don't resolve user names
    -N, --symbolic           resolve hardware names
    -e, --extend             display other/more information
    -p, --programs           display PID/Program name for sockets
    -o, --timers             display timers
    -c, --continuous         continuous listing
    -l, --listening          display listening server sockets
    -a, --all                display all sockets (default: connected)
    -F, --fib                display Forwarding Information Base (default)
    -C, --cache              display routing cache instead of FIB
    -Z, --context            display SELinux security context for sockets
通过帮助文档我们大概能了解每个选项所能实现的功能

通过几个实例来看一下效果

netstat -a
这会显示系统所有的 tcp、udp 以及 unix 连接。

netstat -at
使用t选项只列出tcp连接

netstat -au
使用u选项只列出udp连接

netstat -ax
使用x选项只列出Unix socket连接

netstat -ap
列出进程ID/进程名称

netstat -an
列出端口号而不是服务名

netstat -l
使用l选项只输出监听端口。他不能与a一起使用,因为a选项是会输出所有端口。

netstat -c
持续输出结果

netstat -r
使用r输出网络路由信息

netstat -g
使用g 选项输出  IPV4以及IPV6  的多播组信息

netstat -s
使用 s 选项输出每个协议的统计信息,包括接收/发送的包数量

过滤某个端口
netstat -anp|grep 3306

统计连接数
netstat -anp|grep 3306|wc -l
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值