Where I work, for security and auditing purpose, we have to keep one history file for each session (user, date, terminal, etc in the file name).
Obviously, the HISTFILE
variable, is set to read only (readonly HISTFILE
), therefore a normal user cannot set a different history file (either not root, without changing /etc/profile
).
This is what we have in the /etc/profile
:
EXTENDED_HISTORY=ON
readonly EXTENDED_HISTORY
export EXTENDED_HISTORY
HISTFILE=$HOME/.history/`date +%y%m%d.%H%M%S`.${WHO_USER:-user}.${WHO_TERMINAL:-term}.${SSH_PORT:-port}.${MY_PID:-pid}
readonly HISTFILE
export HISTFILE
The big issue is that we cannot search for old commands, except doing a grep on the older files.
Do you please have a simple workaround or even a better solution to keep the auditing and still be able to share the command history across multiple sessions?
We use ksh and bash.