List The 10 shells you use most
History | awk ' {a[$2]++}end{for (i in a) {print a[i] "i}} ' | Sort-rn | Head
History | awk ' {a[$4]++}end{for (i in a) {print a[$i] " " i}} ' | sort-rn | head
grep-v "#". Bash_history |awk ' {++a[$1]}end{for (i in a) print i,a[i]| " Sort-k2-nr "}" | Head
number of network Connections
Netstat-an | grep-e "^ (TCP)" | cut-c 68-| sort | uniq-c | sort-n #查看状态数连接数
Netstat-ntu | awk ' {print $ ' \ n '} ' | cut-d:-f1 | sort | uniq-c | sort-nr|head-n #统计IP连接数
netstat-an-t | grep ":" | grep established | awk ' {printf "%s%s\n", $5,$6} ' | sort | wc-l #进程连接数
take the NIC IP
/sbin/ifconfig |sed ' s/.*inet addr:\ (. *\) bca.*/\1/g ' |sed-n '/br/{n;p} ' #双网卡绑定用这个
/sbin/ifconfig |sed ' s/.*inet addr:\ (. *\) bca.*/\1/g ' |sed-n '/eth/{n;p} ' #普通网卡用这个
ifconfig eth0 |grep "inet addr:" |awk ' {print $} ' |cut-c 6-or
ifconfig | grep ' inet addr: ' | grep-v ' 127.0.0.1 ' | cut-d:-f2 | awk ' {print '} '
System Information Statistics
dmidecode-t system |grep-e ' Serial ' |awk-f ': ' {print $} ' (serial number query)
cat/proc/cpuinfo | grep CPU | awk-f: ' {print $} ' | SORT|UNIQ-C (number of CPU cores)
dmidecode-t system |grep ' Product ' |awk ' {print $3$4} ' (Single board device type)
Dmidecode | grep-p-A 5 ' Memory Device ' | grep Size | grep-v range|grep-i-V "no module" |sed-r ' s/^\s+//g ' | sort| UNIQ-C (memory size)
Echo '/sbin/ifconfig |sed ' s/.*inet addr:\ (. *\) bca.*/\1/g ' |sed-n '/eth/{n;p} ' hostname ' >>/etc/hosts take IP and Master Machine name directed to/etc/hostname
System Grab Packet Analysis
tcpdump-c 10000-i eth0-n DST port >/root/pkts (tcpdump grab to prevent 80 ports from being attacked when data can be analyzed)
Less | awk ' {printf $ "\ n '} ' | cut-d.-F 1-4 | sort | uniq-c | awk ' {printf $" "$" \ n "} ' | sort-n-t\ +0 (then check I Number of repetitions of p and order from small to large note that the middle of "-t\ +0" is two spaces)
System Process Management
Ps-eo pid,lstart,etime | grep 26871 (Process run time)
lsof-p 10412 (View process Open File 10412 is the PID of the process)
ps-e-O "%c:%p:%z:%a" |sort-k5-nr (view process by memory from large to small)
ps-e-O "%c:%p:%z:%a" |sort-nr (ranked by CPU utilization from large to small)
PS aux |grep mysql |grep-v grep |awk ' {print $} ' |xargs kill-9 (kill MySQL process)
killall-term mysqld Kill the MySQL process:
ps-eal | awk ' {if ($ = = "Z") {print $4}} ' | kill-9 kill Zombie Process
Network card Traffic
dstat-acdgilmnprsttfy (CentOS View network card traffic)
iftop (SUSE System network card traffic)
sar-n DEV 1 (suse system NIC Traffic)
Iotop-o (View the most polished disk of the process)
File Management
Delete a 0-byte file
find-type f-size 0-exec rm-rf {} \;
View 10 large files in a directory
du-cks * | sort-rn | head-n
du-h--max-depth=1/home
This article is from the "System website Operations" blog, please be sure to keep this source http://cgc888.blog.51cto.com/3989433/1694500
Operations Common Shell