日志处理:
cat /usr/local/nginx/logs/access.log|grep \.apk|awk '{print $10}'|awk '{sum += $1} END {print sum}'
cat /usr/local/nginx/logs/access.log-201604011|sed -n "/2016:09:00:00/,/2016:10:00:00/"p|grep "200"|awk '{print $10}'|awk '{sum += $1} END {print sum}'
cat /usr/local/nginx/logs/access.log|sed -n "/2016:09:00:00/,/2016:10:00:00/"p|awk '{print $NF}' |sed 's/"/" /'g|awk '{print $2}'|sed 's/"/ "/'g|awk '{if ($1>3)print $1}'|wc -l
cat tsc-xcall.log|grep "send msd to tmp ok"|awk '{a+=1}END{if(a>10)print "t";else print "f"}'
测试网络路由:
curl -H 'host:183.131.2.238' http://fund.10jqka.com.cn
ping -f -i 0.01 -c 10000 1.1.1.1
traceroute -m 10 -I www.baidu.com
xargs使用方法:
ls /etc/www/*.tar.gz|xargs tar zxf
find $DIR/service/${ip} -type f -name "*20160405*" |xargs gzip -9
tcpdump命令分析:
tcpdump -i eth0 -X -s0 -vnn dst host 183.131.12.145 and dst port 5666
(抓去目的ip和目的端口的数据包)tcpdump -i eth0 -X -s0 -vnn host 54.223.140.178tcpdump -i eth0 -X -s0 -vnn src host 192.168.205.187 or port 5666
(抓去源ip和端口的数据包)tcpdump -i eth0 -nn port 8443 -w 1111.log 抓本机端口包
(抓取端口和ip10.143.130.108访问的数据包)
sudo tcpdump -nn port 80 and host 10.143.130.108tcpdump -i ${NIC} -s 0 -n -vv -c ${NUM} src host ${IP} and dst net 10.142.194.0/24 or dst host 10.20.48.11 -w ${FILE
tcpdump -i eth0 port 1883 -w 1883.iptrace.171119
scp -r dispatcher@192.168.3.215:/home/dispatcher/1883.iptrace.1711177 .
dd 写入磁盘测试
time dd if=/dev/zero of=/test.dbf bs=8k count=300000
tail -f /usr/local/nginx/logs/comment.access.log|awk '$9~/500/'
cpu个数:
cpu个数:cat /proc/cpuinfo|grep 'physical id'|sort|uniq -c|wc -l物理核心数:cat /proc/cpuinfo|grep 'cpu cores'|uniq
逻辑核心数:cat /proc/cpuinfo|grep 'processor'|wc -l查看硬盘大小:smartctl --all /dev/sda
查看网卡流量
watch cat /proc/net/dev
查看端口联通情况,临时加端口
nc -z -w 1 $ip $portnc -l $port 临时加端口
ntpdate同步:
0 5,9,13,17,20,23 * * * /usr/sbin/ntpdate 10.142.132.33 && /sbin/hwclock -w &>/dev/null
*/5 * * * * /usr/sbin/ntpdate 10.142.130.69 && /sbin/hwclock -w
可以取出变动的密码:
cat /dev/urandom | head -1 |md5sum|head -c 5 可以取出变动的密码
导堆栈:
jstack -l 3845 > stack0826.txt
jmap -dump:live,format=b,file=p0826.bin 3845
根据进程id查看程序启动文件位置:
ls -la /proc/ID 根据进程id查看程序启动文件位置
pwdx 10035 根据进程id查看程序启动文件位置
批量修改用户密码:
chpasswd语法1:echo 用户名:密码 |chpasswd语法2:chpasswd > user.txt (文件内容格式为:[user1:passwd]) 普通用户没有权限可以修改755