linux實用命令匯總

來源:互聯網
上載者:User

1,查看linux版本: lsb_release -a.

2,擷取當前核心名稱和其它資訊: uname -a

3,尋找當前檔案夾下所有.mp3檔案,並強制移除: find ./ -name "*.mp3" | xargs rm -rf

4,在目前的目錄下的所有普通檔案中搜尋hostnames這個詞: find . -name /* -type -f -print | xargs grep "hostname"

5,打包檔案example下檔案,除過檔案夾lib下的檔案:tar --exclude example/WEB-INF/lib -zcvf bak/example2010-12-15.tar.gz example/*

6,後台運行程式(啟動進程)
nohup /usr/local/bin/python /var/log/httpd/PythonCode/3G/3g.py >> nohup-3g.out &

7,copy檔案,當檔案已經存在的情況下覆蓋 /cp /var/log/httpd/new.log/var/log/httpd/old.log

8,檔案同步,同步192.168.1.100伺服器上的new.log_2到當前檔案夾下:編輯100上的/etc/rsyncd.conf

添加path = /var/log/httpd
      commnet = counter log

rsync -a 192.168.1.100::counter/new.log_2 .

9,tomcat伺服器的重啟,設定定時任務*/3 * * * * root /root/shell/monitor.sh

在shell下編寫monitor.sh

TOMCAT_DIR=/usr/local/apache-tomcat-6.0.9
SHELL_DIR=/root/shell

cd $SHELL_DIR
pid=`ps -ef|grep "$TOMCAT_DIR"|grep -v grep|awk '{print $2}'`
cp /dev/null result.txt
wget --timeout=10 --spider  --append-output=$SHELL_DIR/result.txt http://192.168.1.100:8080/example/login.jsp
result=`cat result.txt |grep "200 OK"|sed -n 1p`
if [ -z "$result" ]
 then
     kill -9 $pid
     sleep 5
     cd $TOMCAT_DIR/bin/
     . ./myconfig.sh
     ./startup.sh
     date '+%F  %T' >> $SHELL_DIR/times.txt
else
  exit 0
fi

10,查看伺服器負載:top命令是Linux下常用的效能分析工具,能夠即時顯示系統中各個進程的資源佔用狀況,類似於Windows的工作管理員

11, 列印當前系統活動摘要:w 顯示目前登入系統的使用者資訊

12,df 統計檔案系統的使用方式:df -h

13,du統計每一目錄的使用方式:du -sh * 查看每個檔案和目錄的大小

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.