操作伺服器有一段時間了,經常對伺服器進行操作,整理備忘
tail -f -n 200 ..../xxx.log 檢視200行log pwd 檢視目前路徑
find / -name '*value*' 根據檔案名搜尋
權限 chmod 777 -R . 設定檔案夾權限 不要在根目錄使用隻在需要的地方使用
sudo -i 切換至root目錄
su - name 切換到指定目錄 chown [使用者] [檔案] 修改檔案或者目錄的所有者 修改檔案或者目錄的使用者組 chown -R [使用者]:[使用者] [檔案] 同時修改檔案或者目錄的所有者和使用者組
系統指令 date 檢視目前時間 date -s ‘yyyy-MM-dd hh:mm:ss’ 修改系統時間 df -hl 檢視磁盤整體使用情況 du -sh 檢視目前目錄總共占的容量。而不單獨列出各子項占用的容量 du -lh --max-depth=1 檢視目前目錄下一級子檔案和子目錄占用的磁盤容量。 ifconfig eth0 | grep "inet addr" | awk '{print $2}' | awk -F: '{print $2}' 擷取伺服器ip
檢視端口 ps -ef|grep tomcat 檢視tomcat端口
ps -ef --width 200|grep game_server 檢視遊戲服端口
ps -aux --width 200|grep game_server 檢視遊戲服端口 netstat -a 檢視所有檢查端口 netstat -tupln |grep 3734 檢視某個程序監測的端口(3734程序号)
壓縮解壓縮 zip -r xxx.zip ./xxx ./xxx/ 打包多個目錄
zip -r xxx.zip ./xxx xxx.sh xxx.sh 打封包件和目錄
zip -r xxx.zip ./xxx/ ./xxx/ 打包多目錄 unzip [檔案名] 解壓縮zip檔案
SSH指令 ssh -p 端口 ip 遠端SSH通路linux伺服器
ssh -p 22 127.0.0.1 示範 /etc/init.d/sshd status 檢視SSH啟動狀态
記憶體使用情況
free -m 檢視記憶體使用情況 top 檢視記憶體詳細使用情況 free -m | sed -n '2p' | awk '{print "used mem is "$3"M,total mem is "$2"M,used percent is "$3/$2*100"%"}' 檢視伺服器記憶體使用率百分比
Tomcat vim tomcat/conf/server.xml 配置tomcat 端口線程等 sh tomcat/bin/startup.sh 啟動tomcat sh tomcat/bin/shutdown 關閉tomcat