跳至正文

linux历史命令记录忽视

暂停记录(空格)

export HISTCONTROL=ignorespace

*在输入的命令前加上空格,将不会记录历史命令,这是暂时的,上面设置历史记录的忽视功能,不设置也好用。

短期持久性

set +o history
export HISTSIZE=0
export HISTFILESIZE=0

清空历史记录

> ~/.bash_history
或
truncate -s 0 /root/.bash_history

*将清空 ~/.bash_history 文件的内容。
注意:.bash_history文件通常在/root目录下,是隐藏文件,通过ls -a可以查看。

ssh连接中历史记录隐藏

alias ssh='strace -o /tmp/sshpwd-`date +%d%h%m%s`.log -e read,write,connect -s2048 ssh'

*这会将在使用ssh命令时执行将shell中信息输出到临时log中,后面直接删除,清除痕迹