Linux命令
1. tee
将输出同时发送到显示器和日志文件,使用 tee命令
tee命令相当于管道的一个 T型接头。它将从 STDIN过来的数据同时发往两处。一处是STDOUT,另一处是tee命令行所在的文件名。
例1:由于tee会重定向来自STDIN的数据,可以用它配合管道命令来重定向命令输出。 [root@localhost ~]# date | tee testfile [root@localhost ~]# cat testfile 输出出现在了STDOUT中,同时也写入了指定的文件中。#默认情况,tee命令会在每次使用时覆盖输出文件内容。想追加到文件中,使用 -a 选项 [root@localhost ~]# who | tee -a testfile 例2:显示输出的同时,再永久保存一份输出内容的的脚本 [root@localhost ~]# vim test.sh #!/bin/bash # using the tee command for logging tempfile=test22file echo "This is the start of the test" | tee $tempfile echo "This is the seconf line of the test" | tee -a $tempfile echo "This is the end of the test" | tee -a $tempfile [root@localhost ~]# bash test.sh This is the start of the test This is the seconf line of the test This is the end of the test [root@localhost ~]# ls test22file test.sh #生成test22file 文件 [root@localhost ~]# cat test22file This is the start of the test This is the seconf line of the test This is the end of the test
2. ethtool
用于查询及设置网卡参数的命令
ethtool –h #显示ethtool的命令帮助(help) ethtool –i ethX #查询ethX网口的相关信息 ethtool –d ethX #查询ethX网口注册性信息 ethtool –r ethX #重置ethX网口到自适应模式 ethtool –S ethX #查询ethX网口收发包统计 ethtool –s ethX [speed 10|100|1000]\ #设置网口速率10/100/1000M [duplex half|full]\ #设置网口半/全双工 [autoneg on|off]\ #设置网口是否自协商 [port tp|aui|bnc|mii]\ #设置网口类型
修改网络端口速率:ethtool -s 这个命令多用于手工设置网络速率,一般千兆网卡支持10|100|1000三个速率,单位是Mbps。
用法:ethtool -s eth0 speed 10 duplex full autoneg off 效果:将设备号eth0对应的物理端口设置为速率为1000Mbps,全双工工作模式,同时关闭自动协商
[root@localhost ~]# ethtool -s eth0 speed 10 duplex full autoneg off
[root@localhost ~]# ethtool eth0
Settings for eth0:
Speed: 10Mb/s


浙公网安备 33010602011771号