码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS清除用户登录记录和命令历史方法

时间:2020-06-16 13:03:02      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:code   div   roo   root   host   centos   用户登录   结果   成功   

清除登陆系统成功的记录

[root@localhost root]# echo > /var/log/wtmp //此文件默认打开时乱码,可查到ip等信息
[root@localhost root]# last //此时即查不到用户登录信息

清除登陆系统失败的记录

[root@localhost root]# echo > /var/log/btmp //此文件默认打开时乱码,可查到登陆失败信息
[root@localhost root]# lastb //查不到登陆失败信息

清除历史执行命令

[root@localhost root]# history -c //清空历史执行命令
[root@localhost root]# echo > ./.bash_history //或清空用户目录下的这个文件即可

导入空历史记录

[root@localhost root]# vi /root/history //新建记录文件
[root@localhost root]# history -c //清除记录 
[root@localhost root]# history -r /root/history.txt //导入记录 
[root@localhost root]# history //查询导入结果

example 

[root@localhost root]# vi /root/history
[root@localhost root]# history -c 
[root@localhost root]# history -r /root/history.txt 
[root@localhost root]# history 
[root@localhost root]# echo > /var/log/wtmp 
[root@localhost root]# last
[root@localhost root]# echo > /var/log/btmp
[root@localhost root]# lastb 
[root@localhost root]# history -c 
[root@localhost root]# echo > ./.bash_history
[root@localhost root]# history

 

CentOS清除用户登录记录和命令历史方法

标签:code   div   roo   root   host   centos   用户登录   结果   成功   

原文地址:https://www.cnblogs.com/beautiful-code/p/13140121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!