如何更改 .bash_history 文件位置?

Bri*_*ham 14 linux ftp ssh bash command-history

我正在运行 CentOS 6.x 并希望将 .bash_history 移动到其他位置。

我的用户的主目录是(因为我运行的是 VPS),/var/www/vhost/<domain>.<tld>其中 FTP 是可访问的(应该是)。

正因为如此,我改变了AuthorizedKeysFileSSH 连接,~/.ssh/authorized_keys因为 FTP 连接很容易找到它们。

同时我想将.bash_history文件移动到当前用户/home/%u/.bash_history所在的位置%u

Dan*_*ton 22

您需要将您的用户的 HISTFILE 设置为您需要的位置,在 .bash_profile 中为用户设置以下内容,对于新用户将其设置在用户骨架目录中,最有可能是 /etc/skel/.bash_profile

export HISTFILE=/home/$USER/.bash_history
Run Code Online (Sandbox Code Playgroud)