1, top10k統計
grep -a AAAA *.log | awk '{if($12=1234) {print $4}}' | sort | uniq -c | sort -nr | head -10000 > ./top10k
2, shell下自動完成歷史命令
Ctrl+r
3, tcpdump抓包
tcpdump -i eth1 tcp port <端口號> and host <ip地址> -XX -tttt -nnnn -s 0
4, 不影響程序運行的情況下產生core文件
gcore pid
5,測兩臺機器間的網速
5.1,未精確驗證)
機器1執行:
nc -k -l 7777 > /dev/null
機器2執行:
time dd if=/dev/zero bs=1024 count=1024000 | nc 機器1 7777
5.2,精確
vnstat -i eth0 -tr
6,windows下的zip中包含中文文件名或目錄名時,解壓后亂碼
先按windows下的gbk編碼解壓:
LANG=zh_CN.GBK 7za x windows_file.zip
再轉換文件名為linux下的utf-8編碼:
convmv -r -f cp936 -t utf8 --notest --nosmart *
7,ubuntu下進入root shell:
sudo -s
8,開啟關閉某個端口上的網絡通信
iptables -I <INPUT|OUTPUT> -i eth0 -p <tcp|udp...> --dport <端口號> -j <ACCEPT|DROP>
9,命令輸入多行文本
cat [> file] <<EOF
EOF
10,替換文件中的內容
sed -in-place -e 's/old/new/g' test.txt
11,crontab命令執行失敗
首先是crontab執行時的環境變量設置得比較少,確保命令不依賴環境變量;
其次如果命令里用到了百分號,需要轉義:`date --date="3 days ago" "+\%Y\%m\%d"`