linux 系统日志为空,【日志】Linux下清除系统日志的方法

【日志】Linux下清除系统日志的方法

6年前 (2014-12-18)    作者:Jiaozn    分类:Linux    阅读次数:1881

评论(0)

#!/bin/sh

cat /dev/null > /var/log/syslog

cat /dev/null > /var/adm/sylog

cat /dev/null > /var/log/wtmp

cat /dev/null > /var/log/maillog

cat /dev/null > /var/log/messages

cat /dev/null > /var/log/openwebmail.log

cat /dev/null > /var/log/maillog

cat /dev/null > /var/log/secure

cat /dev/null > /var/log/httpd/error_log

cat /dev/null > /var/log/httpd/ssl_error_log

cat /dev/null > /var/log/httpd/ssl_request_log

cat /dev/null > /var/log/httpd/ssl_access_log

把上面的文件根据需要做一下修改,然后保存为clear_logs.sh,然后执行即可。

[root@localhost root]# echo > /var/log/wtmp 此文件默认打开时乱码的,里面可以看到ip等等信息

[root@localhost root]# echo >/var/log/wtmp

[root@localhost root]# last

此时即看不到用户登录信息

清除登陆系统失败的记录,也就是lastb命令看到的记录

[root@localhost root]# echo > /var/log/btmp 此文件默认打开时乱码的

[root@localhost root]# echo > /var/log/btmp

[root@localhost root]# lastb

此时就没有结果输出了

清除历史执行命令

[root@localhost root]# history -c

或者,清空用户目录下的这个文件即可

[root@localhost root]# echo > ./.bash_history

除非注明,发表在“Jiaozn的博客”的文章『【日志】Linux下清除系统日志的方法』版权归Jiaozn所有。

猜你喜欢

评论

发表评论   取消回复

昵称*

E-mail*(建议输入,以便收到博主回复的提示邮件)

网站