命令摘记

macOS上开启vncserver:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -off -restart -agent -privs -all -allowAccessFor -allUsers -clientopts -setvncpw -vncpw passwd

逗号替换为换行符:

awk ‘BEGIN{FS=”,”;OFS=”\n”;}{for(i=1;i<=NF;i++) print $i}’ a.txt
cat a.txt | awk -F”,” ‘{for(i=1;i<=NF;i++) print $i}’

awk ‘{gsub(/,/,”\n”);print}’ a.txt
tr “,” “\n” < a.txt

curl 打印建联等时间:

–compress -w “[$(date +%F\ %T)] %{http_code}|%{time_connect}|%{time_starttransfer}|%{time_total}\n”

测试是否支持会话复用:

openssl s_client -CAfile /root/cacert.pem -connect www.baidu.com:443 -reconnect 2>/dev/null |grep -i ‘new\|reused’

ssl证书打印dns:

openssl x509 -in /usr/local/nginx/conf/ssl/xxxxx.crt -noout -text | grep -i ‘DNS:’ | sed ‘s/DNS:/\’$’\n/g’ | sort -u

url流量占比排行:

cat access.log |awk ‘{sum[$7]+=$5} END { for (i in sum) print sum[i],i}’| sort -k1 -nr | head |awk ‘{a[NR]=$2;x+=(b[NR]=$1)}END{while(++i<=NR)print 100*b[i]/x”%”,b[i]/1024/1024″M”,a[i]}’|column -t

状态码数量及比率统计:

cat access.log |awk ‘{s[$4]++;a++}END{for(k in s){printf(“%-25s%-10d%-4.2f%%\n”,k,s[k],s[k]*100/a)}print “AVG_QPS:”a/300}’ |sort -k2nr

批量修改zabbix_agent上报IP
if [ -z “grep ‘a.b.c.d’ /etc/zabbix/zabbix_agentd.conf” ];then exit 0;else sed -i -e ‘s/a.b.c.d/aa.bb.cc.dd/g’ /etc/zabbix/zabbix_agentd.conf && /etc/init.d/zabbix-agent restart;fi

域名过期时间不准
sed -i ‘/fund/i\ “\\\\.fun$” = “whois.nic.fun”;’ /etc/jwhois.conf

修改自增数值:
SELECT auto_increment FROM information_schema.tables where table_schema=”aaa” and table_name=”bbb”;
alter table bbb_white AUTO_INCREMENT = 142;

多线机房路由测试:
ip route get to a.b.c.d

ip route get to e.f.g.h

ip route get to i.j.k.l

观察日志:

watch -n 1 wc -l /var/log/access.log

流量检查:

sar -f /var/log/sa/sa$(date -d ‘-1 day’ +%d) -s 18:00:00 -e 21:00:00 -n DEV 2> /dev/null | sed -n ‘/^Average:[ ]*\(eth\|em\|bond\)/p;3p’ | awk ‘BEGIN {sp = 0} {if (NF == 9 && $1 ~ /^Average:/) {if (sp < $6) {sp = $6; ifname = $2;};} else if ($7 == “txbyt/s”) {sp = sp / 1024 / 1024 * 8;} else if ($7 == “txkB/s”) {sp = sp / 1024 * 8;};} END {printf “%.2f\n”, sp}’
1453.14

删除策略路由:

ip rule
ip ru del prio xxxxx

Print Friendly

发表评论

电子邮件地址不会被公开。 必填项已用*标注