10
4
I'm running CentOS 6.x and want to move the .bash_history to a different location.
The home directories of my users are (because I run a VPS) in /var/www/vhost/<domain>.<tld> which is FTP accessible (and it should be).
Because of this, I have changed the AuthorizedKeysFile for SSH connections out of the normal ~/.ssh/authorized_keys since FTP connections would easily be able to locate them.
At the same time I want to move the .bash_history file to /home/%u/.bash_history where %u is the current user.
1Thanks for how to set it up for new users automatically as well. – Brian Graham – 2014-05-30T20:23:42.820
As you are running a VPS I assumed it might come in handy. :) – Daniël W. Crompton – 2014-05-30T20:57:10.677
one note... this needs to be pretty early in the RC file parsing. As soon as anything gets written to history, any changes to this VAR are ignored. – Rich Homolka – 2014-05-30T21:04:14.673
@RichHomolka according to the man file changes to HISTFILE aren't ignored, notably:
The name of the file in which command history is saved (see HISTORY below). The default value is ~/.bash_history. If unset, the command history is not saved when an interactive shell exits.– Daniël W. Crompton – 2014-05-30T21:21:17.453@DaniëlW.Crompton I agree :) I use this to have separate history files based on the
ttycommand. My point was WHEN you set it. At some point the location is fixed and further changes are ignored. – Rich Homolka – 2014-05-30T21:39:22.243@RichHomolka that must depend on your distribution. I just tried it on bash under Ubuntu, Debian and OSX, all let me change the HISTFILE mid stride. – Daniël W. Crompton – 2014-05-30T22:00:49.903