Linux常用命令

大小写转换

tr a-z A-Z|tr A-Z a-z

查看头/末行

head -n 10/tail -n -10

服务器抓包

tcpdump -i any host x.x.x.x -s 0 -vv -w test.cap

查看CPU使用率

top -n 2|grep Cpu|tail -n 1|awk '{print $2}'

awk分隔符

awk -F"[@ /t]" '{print $2,$3}' awk -F"['<wtran>''</wtran>']" '{print $2}'

重复次数统计

uniq -c

总数值统计

awk -F '?| ' '{a[$1]+=$NF}END{for(url in a) print url,a[url]}'

10天的文件删除

find /tmp/hadoop-flume/s3 -mtime +10 -exec rm -rf {} \;

主备网卡切换

ifenslave -c bond0 eth1

for循环过滤文件

for file in $(ls accesslog*20161125*_*|grep -v tar.gz);do echo **************$file***********; zcat $file
file=`ls accesslog*|grep -v tar.gz`;cat $file |grep HIT|wc -l

SUSE修改主机名

export HOSTNAME=JSYD_IVS_WX_4A;echo $HOSTNAME>/etc/HOSTNAME;/etc/rc.d/boot.localnet stop;/etc/rc.d/boot.localnet start;hostname $HOSTNAME

删除text开头行

sed -i '/^'text'/d' file

替换10行.为-

sed -i '10s/\./\-/g' file

查mac地址

cat /sys/class/net/eth0/address

查到空行截止

sed '/0309/,/^$/p;d'

删除名称进程

kill -9 $(ps -ef|grep wrf|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ')

无应答修改密码

echo 'password' | passwd --stdin root

posted @ 2020-09-21 09:43  LEAUS  阅读(154)  评论(0)    收藏  举报