如何让历史记录不记录敏感命令
2016-12-12 17:46
260 查看
有时候为了服务器安全,防止别人窥探我们输入的命令,我们可以清空历史记录,而更多的时候,我们选择的是在输入特殊命令时候,强制历史记录不记住该命令。实验方法:先执行export HISTCONTROL=ignorespace 命令,然后依次输出ls -tra ,pwd和service mysqld start 的命令,当执行第三个命令的时候,我们选择不记住该命令。
[root@VM_96_242_centos ~]# export HISTCONTROL=ignorespace
[root@VM_96_242_centos ~]# ls -ltr
total 168
-rw-r--r-- 1 root root 5520 Dec 25 2014 install.log.syslog
-rw-r--r-- 1 root root 12754 Dec 25 2014 install.log
-rw------- 1 root root 2005 Dec 25 2014 anaconda-ks.cfg
-rw-r--r-- 1 root root 12 Dec 9 21:11 a.txt
[root@VM_96_242_centos ~]# pwd
[root@VM_96_242_centos ~]# service mysqld start (注意这条命令的最前面是一个空格)
然后我们来查看历史记录
[root@VM_96_242_centos ~]# history |tail -3
844 2016-12-12 17:01:55 ls -ltr
845 2016-12-12 17:01:59 pwd
846 2016-12-12 17:02:36 history |tail -3
是不是发现我们刚刚执行的,service mysqld start 没有了
注意:如果不想让历史记录记住哪条命令,直接在执行命令的时候,添加空格就可以。
当然哪天你想清空所有历史命令可以执行:
[root@VM_96_242_centos ~]# history -c //清空所有记录
[root@VM_96_242_centos ~]# history //查看是否被清空
1 2016-12-12 17:12:12 history
[root@VM_96_242_centos ~]#
[root@VM_96_242_centos ~]# export HISTCONTROL=ignorespace
[root@VM_96_242_centos ~]# ls -ltr
total 168
-rw-r--r-- 1 root root 5520 Dec 25 2014 install.log.syslog
-rw-r--r-- 1 root root 12754 Dec 25 2014 install.log
-rw------- 1 root root 2005 Dec 25 2014 anaconda-ks.cfg
-rw-r--r-- 1 root root 12 Dec 9 21:11 a.txt
[root@VM_96_242_centos ~]# pwd
[root@VM_96_242_centos ~]# service mysqld start (注意这条命令的最前面是一个空格)
然后我们来查看历史记录
[root@VM_96_242_centos ~]# history |tail -3
844 2016-12-12 17:01:55 ls -ltr
845 2016-12-12 17:01:59 pwd
846 2016-12-12 17:02:36 history |tail -3
是不是发现我们刚刚执行的,service mysqld start 没有了
注意:如果不想让历史记录记住哪条命令,直接在执行命令的时候,添加空格就可以。
当然哪天你想清空所有历史命令可以执行:
[root@VM_96_242_centos ~]# history -c //清空所有记录
[root@VM_96_242_centos ~]# history //查看是否被清空
1 2016-12-12 17:12:12 history
[root@VM_96_242_centos ~]#
相关文章推荐
- 如何让历史记录不记录敏感命令
- 如何在WinDBG里保存运行过的命令的历史记录?
- git学习------>如何用git log命令来查看某个指定文件的提交历史记录
- 如何清除Linux操作系统命令的历史记录
- 如何让python idle有命令自动补全和查看历史记录的方法
- 如何清除Linux操作系统命令的历史记录 .
- 如何消除TextBox框中显示的历史记录?
- asp.net网站如何保存历史访问记录
- 如何向IE的历史记录添加记录?
- 如何记录下其他人telnet到Cisco设备后输入的每一条命令的方法(转)
- 如何从硬盘驱动器检索已删除的历史记录
- 如何快速清除IE8浏览器的历史记录
- 清空历史命令记录和清除登陆系统记录方法
- 取消root命令历史记录以增加安全性
- 如何清除QQ登陆栏的历史记录
- 如何记录Production Order and Processing Order的历史修改记录
- 如何让ie8地址栏下拉框里不显示历史记录和收藏夹
- 如何清除任务栏被隐藏图标的历史记录
- 如何消除TextBox框中显示的历史记录?
- 教你如何清除搜索计算机的历史记录