-
普通賬戶(userxxx)使用sudo指令設定:
chmod u+w /etc/sudoers 添加寫權限
/etc/sudoers作如下修改
在 root ALL=(ALL:ALL) ALL處添加
userxxx ALL=(ALL:ALL) ALL
chmod u-w /etc/sudoers 删除寫權限
2. gzip怎麼把.gz檔案解壓到指定目錄下?
tar xvzf foo.tar.gz -C /some/where/you/want
3 . 運維監控的幾個指令
找出使用CPU最多的前10名程序
ps -auxf | sort -nr -k 3 | head -10
找出消耗記憶體最多的前10名程序
ps -auxf | sort -nr -k 4 | head -10
最占空間檔案名(找1G以上的大檔案)
sudo find / -type f -size +1024000k -exec du -h {} \;
4.查找系統中的大檔案,并删掉
find . -type f -size +1G -print0 | xargs -0 ls -l
cat /dev/null|sudo tee /home/changhongit/loving/cpx-gateway-setting-event-process-qa/cpx-gateway-setting-event-process-qa.log
tee bigfile:是标準輸出指令,将/dev/null 的内容(為空)輸入到大檔案bigfile中,相當于把bigfile置空,不能直接rm删除,否者删除了仍然不釋放,要重新開機才行。
find /usr/local/backups -mtime +10 -name "*.*" -exec rm -rf {} \;
5.find 的幾種用法
1)查找檔案并移動到某個目錄下
find /backup/abc/ -type f -name *.log|xargs -I '{}' mv {} ./waitmovedfiles
find /backup/ -type f -name *.log -exec mv {} ./waitmovedfiles/ \;
2) 查找并處理,反引号用法
rsync -avz `find /backup -type f -name *.tar.gz -mtime +7` [email protected]::backup/ --password-file=/etc/rsync.password
3)-exec 和xargs用法
find /backup -type f -name *.tar.gz -mtime +7 -exec ls -l {} \;
find /backup -type f -name *.tar.gz -mtime +7|xargs ls -l