很實用的linux營運常用命令及知識! 2

來源:互聯網
上載者:User

日常經典命令集合:

1、尋找所有tar檔案然後移動到目錄:find . -name “*.tar” -exec mv {} ./backup/ ; 2、尋找for i in `find . -name *.html|sed ‘s/.//g’|sed ‘s/html/.html/g’` ;do echo http://192.168.0.170:8017$i ; done

3、去掉行首的.字元:
find . -name *.html|sed ‘s/^.//g’4、尋找類型屬於檔案的,然後備份到其他目錄:find . -name nginx.conf.tgz -exec cp {} dir/ ;5、監控linux磁碟分割,如果空間大於90%,發送郵件給Linux SA
(1)、列印根分區大小
df -h |sed -n ‘//$/p’|awk ‘{print $5}’|awk -F”%” ‘{print $1}’
(2)、if條件判斷該大小是否大於90,如果大於90則發送郵件警示while sleep 5m
dofor i in `df -h |sed -n ‘//$/p’ |awk ‘{print $5}’ |sed ‘s/%//g’`
do
echo $iif [ $i -gt 90 ];then
echo “More than 90% Linux of disk space ,Please Linux SA Check Linux Disk !” |mail -s “Warn Linux / Parts is $i%”wugk@map.com
fi
done
done6、統計apache訪問日誌,訪問量排在前20 ip地址:cat access.log |awk ‘{print $1}’|sort|uniq -c |sort -nr |head -207、在所有行前添加http://img.map.com,並在最後添加/
sed -e ‘s/^/http://img.map.com/maplite/map/subway/1.1//’ -e ‘s/$///’ a.txt
8、找到當前行,然後在修改該行後面的參數:
sed -i ‘/SELINUX/s/disabled/enforcing/’ /etc/selinux/config
9、尋找並修改目錄下所有檔案夾的名字:
find . -name “NaviInfo.2010.12.0″ |xargs rename NaviInfo.2010.12.0 NaviInfo.2010.12.1
10、查看apache並發串連數,及相關轉寄狀態:
netstat -n |awk ‘/^tcp/’|awk ‘{print $NF}’|sort |uniq -c |sort -nr
netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’ 11、列印出一個檔案裡面最大和最小值:
cat a.txt |sort -nr|awk ‘{}END{print} NR==1′
cat a.txt |sort -nr |awk ‘END{print} NR==1′
這個才是真正的列印最大最小值:sed ‘s/ / /g’ a.txt |sort -nr|sed -n ’1p;$p’12、使用snmpd抓取版本為v2的cacti資料方式:
snmpwalk -v2c -c public 192.168.0.241
13、修改文本中以jk結尾的替換成yz:
sed -e ‘s/jk$/yz/g’ b.txt
14、網路抓包:tcpdump
tcpdump -nn host 192.168.56.7 and port 80 抓取56.7通過80請求的資料包。
tcpdump -nn host 192.168.56.7 or ! host 192.168.0.22 and port 80 排除0.22 80連接埠!
tcp/ip 7層協議 物理層–資料連結層-網路層-傳輸層-會話層-展示層-應用程式層。15、H3C配置團體名配置:首先設定snmp版本如下:
snmp-agent sys-info version v1 v2c ,然後設定團體名:snmp-agent community read public
 16、顯示最常用的20條命令:
cat .bash_history |grep -v ^# |awk ‘{print $1}’ |sort |uniq -c |sort -nr |head -20


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.