个人实用语句收集

MC数据库查询语句
select * from t_conf_info t where t.objectid = '10037' order by t.version desc;

解析证书内容
openssl x509 -noout -text -in ca.pem

vim显示不可见字符
:set invlist
:set nolist(退出)

openresty编译打包:
./configure --prefix=/home/linyihan/code/trunk/content_origin/opensource/nginx/tmp -j8 --with-cc-opt=-I/home/linyihan/code/trunk/content_origin/opensource/nginx/include --with-ld-opt=-L/home/linyihan/code/trunk/content_origin/opensource/nginx/lib --add-module=../nginx-rtmp-module-1.1.11 --with-http_worker_info_module --with-http_v2_module --with-ld-opt=-Wl,-rpath,''

查看动态链接库依赖关系:ldd cjson.so

查看动态链接库函数:nm cjson.so

查看目录占用空间大小:du -h --max-depth=1 .

查看文件大小(单位为M):ll --block-size=M

抓包语句:
tcpdump -i any host ip -s 0 -w test.pcap

linux将tab转换为4个空格:
:set expandtab
:%ret! 4

设定tab宽度为4个字符:
:set tabstop=4

设定自动缩进为4个字符:
:set shiftwidth=4

可以保存在.vimrc里永久生效

根据ip查找网卡名:
ifconfig|grep -w -B 1 "addr:${phy_ip}"|sed -n '1p'|awk '{print $1}'

查看网卡带宽:
sar -n DEV 1

后台定时任务脚本:
while : ;do rcmag cli showdevinfo -a; sleep 1; done;

CPU过载脚本:
for i in seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l); do dd if=/dev/zero of=/dev/null & done

解决ssh超时连接断开:
ClientAliveInterval 60
ClientAliveCountMax 3

给运行程序设置依赖库文件路径:
ldd 发现找不到一些依赖库文件,在/etc/ld.so.conf里添加依赖库文件路径,执行ldconfig命令即可

nginx单进程:

daemon off;

master_process off;

awk统计条目数量:
awk '{t[$1]++}END{for(i in t)print i","t[i]}'

awk计算平均值:
cat count.txt | awk '{sum+=$1} END {print "Average = ", sum/NR}'

查看进程在哪个cpu上运行
ps -o pid,psr,comm -p

sar查看cpu空闲率
sar 1 时间

采集mag 物理ip:
grep -i "<ServiceIp.>.</ServiceIp.>" /home/huawei/mdn2000/mag/conf/config.xml | awk -F">" '{print $2}' | awk -F"<" '{print $1}' | awk -F" " '{print $1}' | sort | uniq
grep -i "<Ext.
PublicIP.>.</Ext.PublicIP.>" /home/huawei/mdn2000/mag/conf/config.xml | awk -F">" '{print $2}' | awk -F"<" '{print $1}' | awk -F" " '{print $1}' | sort | uniq

给某个进程绑核:
taskset -pc 0 86760

core配置:
编译选项:--with-debug --with-cc-opt='-O0 -g'

执行 ulimit -c 1024 (ulimit -c 0)
worker_rlimit_core 10000M;
working_directory /home/mag/data/core/;
echo "/home/mag/data/core/core-%e-%p-%t" > /proc/sys/kernel/core_pattern

查看udb命中率:
udbinfo -showstat

查看已删除文件:
lsof -n |grep deleted

查看进程内的线程号:
ps -T -p 进程号

查看线程运行状态:
gstack 线程号

使用如下命令查看进程使用文件句柄数:
lsof -p 21543(linux进程号)

ll /proc/linux进程号/fd

猜你喜欢

转载自www.cnblogs.com/linyihan/p/11234037.html