5

Using Red Hat Enterprise Linux is it possible to place a global option that whenever a user exits an SSH connection the BASH history for that user is cleared?

4

5 回答 5

1

我知道你可以手动运行

history -c

我想你可以把它放到你的~/.bash_logout.

于 2013-10-08T19:47:20.850 回答
1

/etc/bash.bash_logout脚本中,您可以输入:

unset HISTFILE

的默认HISTFILE值为~/.bash_history。用户可以将其设置为任何他们想要的。如果未设置,则注销过程不会将 RAM 中的历史信息写入历史文件。

于 2013-10-08T19:48:59.913 回答
0

用户始终可以将他们的历史记录保存到非标准文件并在下次登录时重新加载,因此从全局角度来看,您无法阻止它。

例如,Bob 可能会在他的~/.bash_login:

HISTFILE=~/my_secret_history_file
于 2013-10-08T20:29:17.990 回答
0

当需要让历史记录为空时 - 我使用符号链接它们到 /dev/null...

lrwxrwxrwx  1 root root    9 Dez 16 19:10 .ash_history -> /dev/null
lrwxrwxrwx  1 root root    9 Dez 16 19:10 .bash_history -> /dev/null

...然后键入命令的历史记录仅适用于当前会话。
启动一个新的 shell,启动一个新的空临时历史记录。
为普通用户对它们进行符号链接/dev/null必须通过以下方式完成:root

于 2021-03-15T12:34:53.073 回答
0

将以下内容放入~/.bash_logout

echo > $HISTFILE

这将在用户注销时删除保存的历史记录,但在用户登录时会保留有用的运行历史记录。

于 2021-03-15T12:16:02.373 回答