如何让历史记录不记录敏感命令

发布时间:2020-06-28 12:10:40 作者:维度2018
来源:网络 阅读:463

 有时候为了服务器安全,防止别人窥探我们输入的命令,我们可以清空历史记录,而更多的时候,我们选择的是在输入特殊命令时候,强制历史记录不记住该命令。实验方法:先执行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 ~]# 


推荐阅读:
  1. Centos History 命令历史记录添加执行时间
  2. oracle命令历史记录工具(rlwrap)

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

安全 服务器 service

上一篇:手势 UIGestureRecognizer 轻拍手势

下一篇:jquery之动态输入字数

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》