1.使用 nload 工具查看
安装工具 sudo yum install nload # 查看所有网卡实时网速 sudo nload -m # 查看指定网卡实时网速 sudo nload eth0 -m
2.通过 ifconfig 实时查看
watch -n 1 ifconfig
3.通过脚本查看
#!/bin/bash awk 'BEGIN{ OFMT="%.3f"; devf="/proc/net/dev"; while(("cat "devf) | getline) { if($0 ~ /:/ && ($10+0) > 0) { split($1,tarr,":"); net[tarr[1]]=$10+tarr[2]; print tarr[1],$10+tarr[2]; } } close(devf); icount=0 while((system("sleep 1")) >=0) { icount +=1 system("clear"); while( getline < devf ) { if($0 ~ /:/ && ($10+0) > 0) { split($1,tarr,":"); if(tarr[1] in net) { print tarr[1],":",($10+tarr[2]-net[tarr[1]])*8/1024,"kb/s"; net[tarr[1]]=$10+tarr[2]; } } } close(devf); if (icount>100) {break;} } }'
icount=计数100次之后自动退出。