linux

常用指令

发布时间:7年前热度: 3509 ℃评论数:

查看机器型号 

# dmidecode | grep "Product Name"  

# dmidecode -t 2

  SYS-6028R-WTRT

查看网卡信息 

# dmesg | grep -i eth

查看内存型号

# dmidecode -t memory |grep "Part Number"

# dmidecode|grep -P -A5 "Memory Device"|grep Size

查看CPU信息(型号) 

# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c 

      8  Intel(R) Xeon(R) CPU            E5410   @ 2.33GHz 

(看到有8个逻辑CPU, 也知道了CPU型号) 


# cat /proc/cpuinfo | grep physical | uniq -c 


CPU温度查看

# yum install lm_sensors -y

# sensors |awk '{print $3}' |egrep '^\+' |sed  's/\+//' | sort |tail -1


文件数打开查看

# lsof|awk '{print $2}'|sort|uniq -c|sort -nr|more


连接数查看

# ss  -tan|awk 'NR>1{++S[$1]}END{for (a in S) print a,S[a]}'


查看磁盘信息


# smartctl -x -d sat /dev/sda

# smartctl -x -d sat /dev/sdh |grep "Device Model"

# cat /proc/scsi/scsi |grep ATA|wc -l



查找时间段的日志


#tail -n 20000 /data/logs/test.log >/data/logs/time_log/1.log 

# cat 1.log |egrep "2018-06-07" |sed -n '/16:09:00/,/16:20:00/p' >2.log



服务器缓存文件内存修改为192G ,


# mount tmpfs /dev/shm -t tmpfs -o size=196608m


打包过滤日志文件

# tar -cvzf cvr_playback20180620.tar.gz cvr_playback --exclude=*.log*


mysql表空间占用大小查询

select table_schema,table_name,round(DATA_LENGTH/1024/1024,2)+round(index_LENGTH/1024/1024,2)+round(data_free/1024/1024,2) as data from information_schema.TABLES where table_schema!='mysql'  order by 3 desc


删除文件中重复行的记录

awk '! a[$0]++'  file > file1

awk '!($0 in a){a[$0];print}'  file   > file


找出文件中重复行的记录

[root@junun script]# cat origin

order-app

order-app

portal_special-app

portal_tenant-app

premetting-app

procurement-app

purchase-app

report_print-app

premetting-app

report_statistics-app

supplier-app

purchase-app

purchase-app

[root@localhost script]# awk '{a[$0]+=1}END{for(i in a) {if(a[i] > 1) print i}}' origin

purchase-app

order-app

premetting-app


找出指定数据库 满足 where 条件的所有的表

mysql -u root -D  test  -pxxxxxx -s -e "show tables" | xargs -I "@@" mysql -u root  -D test -pxxxxxx -e "select uid,'\`@@\`' from  \`@@\`  where uid = '666666';" 2>&1 | grep -P '^\d+.*' | sed 's#.*`\(.*\)`.*#\1#g' | sort | uniq


K8S监控项目

https://github.com/marksugar/k8s-pgmon#wechat_config


压测利器、流量重放

https://github.com/buger/goreplay


常用,指令

手机扫码访问