Another way - with advantage of giving the date and time of commands entered - is to use the bash DEBUG trap as a hook to log all commands entered from interactive shell to syslog or elsewhere. for example, create a file in /etc/profile.d/logcmd.sh , with:
function logcmd
{
unset PROMPT_COMMAND
if [ -n "$BASH_COMMAND" ] && [ -n "$PS1" ]; then
logger -d -p local6.debug -t bash "${USER}[$$]: $BASH_COMMAND"
fi
}
[ -n "$PS1" ] && trap logcmd DEBUG
The PS1 check prevents from logging commands from inside scripts that would flood the log.
The unset PROMPT_COMMAND avoids useless output to syslog.
Note: to log commands from ssh sessions, you also need to add something in bashrc, for example:
if [ -n "$SSH_CLIENT" ] && [ -n "$BASH_EXECUTION_STRING" ]; then
logger -d -p local6.debug -t bash "${USER}[$$]: $BASH_EXECUTION_STRING"
fi
See also http://superuser.com/questions/666021/bash-preexecute and bash man page.