linux常用操作

时间:2016-10-14
top -Hp 5917      //看进程中的各线程
sar 2 30        //看cpu
sar -d 2 10   //看磁盘
iostat -m -x 1 1000   //看磁盘
sar -n DEV 2 100 查看当前服务器的网络流量信息

cat c.txt | awk '{system("echo "$0" " "`./getip.sh "$3"`")}' | awk '{print $1" "$2" "$3" "$4}'
//直接运行curl容易出错,会被卡住
cat c.txt | awk '{system("echo "$0" " "`curl -s http://www.163.com/ip/exchange?ip="$3"`")}' | awk '{print $1" "$2" "$3" "$4}' > r2.txt

//端口映射
ssh -C -f -N -g -L 3306:223.202.109.146:3306  223.202.109.146  -p 3389
ssh -C -f -N -g -L 3389:42.121.104.10:22  tornado_@42.121.104.10  -p 22


nginx 动态加载

./nginx -t
./nginx -s reload

select * into outfile '/tmp/1.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' from op_log where 1=1
mysql test < /backup/yejr.txt
LOAD DATA local INFILE '/root/rltmp.txt'   INTO TABLE local_tmp  FIELDS TERMINATED BY ',' (user_id, area_code)
CREATE TEMPORARY  TABLE `local_tmp`

//看硬盘型号
hdparm -i /dev/sda
smartctl -a /dev/hda
dmesg |grep Vendor   ---------cat /var/log/dmesg  | grep Vendor
cat /proc/scsi/scsi    //
//看机器型号
dmidecode -q -t system

//哪个进程占用io
echo 1 > /proc/sys/vm/block_dump
dmesg -c


while true; do echo `date` $(ping -c 1 163.com  |grep "^64 bytes from"); sleep 1; done

//合并2个文件
paste -d , a.txt b.txt


文本处理

for i in {20140608..20140609}; do  ./time2.sh $i >>uptime2.txt ;done;
tail result_2016-09-21.csv  | awk -F "\x1" '{print substr($1,1,1),$2}'

tail result_2016-09-21.csv  | sed 's/\x1/,/g'


【推荐】 网站访问量pv统计-排除爬虫
【推荐】 ping返回DUP!的问题
【推荐】 [Centos]openvpn服务端的安装(easy-rsa3)
【推荐】 chm文件编辑方法