linux bbs.linuxtone.org
1. : ps -eo "%C : %p : %z : %a"|sort -k5 -nr2. ; : ps -A ;lsof -p PID ,-_-!!3. IP ( grep,awk,cut )ifconfig eth0 |grep "inet addr:" |awk '{print $2}'|cut -c 6- (cut -c 6- , sed 's/addr://g' )4. , awk '{arr[$1]+=1 }END{for(i in arr){print arr"\t"i}}' | sort -rn ( sort -rn FILENAME |uniq -c |sort -rn)5. 10 sed -e "s/| /
/g" ~/.bash_history | cut -d ' ' -f 1 | sort | uniq -c | sort -nr | head (
cut -d ' ' -f 1 , ,sort ,uniq -c ,sort -nr ,)
6. Nginx ( )ps -ef|grep -v grep |grep nginx|awk '{print $2}' for i in `ps aux | grep nginx | grep -v grep | awk {'print $2'}` ; do kill $i; done7. , G,M,K 。du -b --max-depth 1 | sort -nr | perl -pe 's{([0-9]+)}{sprintf"%.1f%s", $1>=2**30? ($1/2**30, "G"): $1>=2**20? ($1/2**20, "M"):$1>=2**10? ($1/2**10, "K"): ($1, "")}e'shaw :du -hs $(du -sk ./`ls -F |grep /` |sort -nr |awk '{print $NF}') , 。 。8. linux buffer cachesync && echo 3 > /proc/sys/vm/drop_caches9. for i in *; do mv "$i" "$(echo $i|tr A-Z a-z)"; done10. vim ^M 1)dos2uninx filename 2)sed -e 's/^M//' filename3)vim :s/^M//gc4)col -bx newfile5)tr -s "\r
" "
" newfile11. arp arp -n|awk '/^[1-9]/ {print "arp -d "$1}'|sh12. arp cat /proc/net/arp | awk '{print $1 " " $4}' |sort -t. -n +3 -4 > /etc/ethers perl ? 13. perl -ne 'm/^([^#][^\s=]+)\s*(=.*|)/ && printf("%-35s%s
", $1, $2)' /etc/my.cnf
1. 0
find -type f -size 0 -exec rm -rf {} \; ( -ok -exec rm -rf ;rm -rf {} \ )
2.
ps -e -o "%C : %p : %z : %a"|sort -k5 -nr
3. cpu
ps -e -o "%C : %p : %z : %a"|sort -nr
4. cache URL
grep -r -a jpg /data/cache/* | strings | grep "http:" | awk -F'http:' '{print "http:"$2;}'
5. http TCP :
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
6.sed -i '/Root/s/no/yes/' /etc/ssh/sshd_config sed Root , Root , no yes.
7.1. mysql :ps aux|grep mysql|grep -v grep|awk '{print $2}'|xargs kill -9
( awk )
pgrep mysql |xargs kill -9
killall -TERM mysqld
kill -9 `cat /usr/local/apache2/logs/httpd.pid`
PID8. 3 :ls /etc/rc3.d/S* |cut -c 15- ( cut , )9. SHELL , EOFcat < /root/pkts
39. IP "-t\ +0"
# less pkts | awk {'printf $3"
"'} | cut -d. -f 1-4 | sort | uniq -c | awk {'printf $1" "$2"
"'} | sort -n -t\ +0
40. php-cgi
netstat -anp | grep php-cgi | grep ^tcp | wc -l
41. iptables ***
netstat -an | grep -v LISTEN | awk ‘{print $5}’ |grep -v 127.0.0.1|grep -v ip|sed “s/::ffff://g”|awk ‘BEGIN { FS=”:” } { Num[$1]++ } END { for(i in Num) if(Num>8) { print i} }’ |grep ‘[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}’| xargs -i[] iptables -I INPUT -s [] -j DROP
Num>8 , netstat -an IP 。 ip ip 42. CPU ?
# ps -eo pid,args,psr
43.
dmidecode -s system-product-name
44.perl , ?perlcc -B -o webseek webseek.pl
45. var M , 。find /var -type f | xargs ls -s | sort -rn | awk '{size=$1/1024; printf("%dMb %s
", size,$2);}' | head var 100M , find /var -size +100M -type f | tee file_list | wc -l46. sed
sed -i "s/varnish/LTCache/g" `grep "Via" -rl /usr/local/src/varnish-2.0.4`sed -i "s/X-Varnish/X-LTCache/g" `grep "X-Varnish" -rl /usr/local/src/varnish-2.0.4`
47.
dmidecode -s system-product-name
48. wget user-agent
wget -m -e robots=off -U "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6" http://www.example.com/
50. ( M )
du $1 --max-depth=1 | sort -n|awk '{printf "%7.2fM ----> %s
",$1/1024,$2}'|sed 's:/.*/\([^/]\{1,\}\)$:\1:g'
51. CND
ls -l | awk '/^d/' | wc -l
ls -l | awk '/^-/' | wc -l
find ./ -type f -print | wc -l
find ./ -type d -print | wc -l
: find ./ -name "*.jpg" -exec wc -c {} \;|awk '{print $1}'|awk '{a+=$1}END{print a}'
53. IO
wget -c http://linux.web.psi.ch/dist/scientific/5/gfa/all/dstat-0.6.7-1.rf.noarch.rpmdstat -M topio -d -M topbio
54. ( )
awk '{for(i=2;i<=NF;i++) if(i!=NF){printf $i" "}else{print $i} }' list
55. 256
for i in {0..255}; do echo -e "\e[38;05;${i}m${i}"; done | column -c 80 -s '