现在可以在网上公开获得的日志清除程序代码很粗糙,我曾经看到过最夸张的清日志的代码像这样:
rm -rf /var/log/lastlog ; rm -rf /var/log/telnetd ; rm -rf /var/run/utmp ; rm -rf /var/log/secure ; rm -rf /root/.ksh_history ; rm -rf /root/.bash_history ; rm -rf /root/.bash_logut ; rm -rf /var/log/wtmp ; rm -rf /etc/wtmp ; rm -rf /var/run/utmp ; rm -rf /etc/utmp ; rm -rf /var/log ; rm -rf /var/adm ; rm -rf /var/apache/log ; rm -rf /var/apache/logs ; rm -rf /usr/local/apache/log ; rm -rf /usr/local/apache/logs ; rm -rf /var/log/acct ; rm -rf /var/log/xferlog ; rm -rf /var/log/messages ; rm -rf /var/log/proftpd/xferlog.legacy ; rm -rf /var/log/proftpd.access_log ; rm -rf /var/log/proftpd.xferlog ; rm -rf /var/log/httpd/error_log ; rm -rf /var/log/httpd/access_log ; rm -rf /etc/httpd/logs/access_log ; rm -rf /etc/httpd/logs/error_log ;rm -rf /var/log/news/suck.notice ; rm -rf /var/spool/tmp ; rm -rf /var/spool/errors ; rm -rf /var/spool/logs ; rm -rf /var/spool/locks ; rm -rf /usr/local/www/logs/thttpd_log ; rm -rf /var/log/thttpd_log ; rm -rf /var/log/ncftpd/misclog.txt ; rm -rf /var/log/ncftpd.errs ; rm -rf /var/log/auth ; rm -rf /root/.bash_history ; touch /root/.bash_history ; history Cr
整个一rm集合,要是服务器跑了很长时间,积累了很多日志。你这样一删除,的,你帮他省事了,他也省事,一眼就看出有人进来了。
先不说其他,用rm删除就不可取,正确的删除文件做法是用shred
shred -n 31337 -z -u file_to_delete
这样多次擦除才够安全。
温馨提示:答案为网友推荐,仅供参考