Rootop 服务器运维与web架构

清空history历史命令记录

今天在清空历史命令时候只记得cat null设备到隐藏文件中,man了一下找到c参数,作此记录。

在用户家目录下有几个隐藏的文件:

~/.bash_history 存放用户历史命令。
~/.bash_profile 用户登陆系统时执行。
~/.bash_rc 用户登陆系统或者打卡新的终端shell时执行。
~/.bash_logout用户退出系统时执行。

如果要清除执行过的历史命令有两种方法:
1、history -c  
#Clear the history list by deleting all the entries.#

2、/dev/null 是一个空的块设备,没有任何内容,可以cat此设备然后输出到 .bash_history 文件中。

[root@localhost ~]# cat /dev/null >~/.bash_history

原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/1459.html

作者:Venus

服务器运维与性能优化

评论已关闭。