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 * 查看每個檔案和目錄的大小