在/etc/profile中添加下面内容:
export LC_ALL=C
TMOUT=3600
HISTFILESIZE=2000
HISTSIZE=2000
HISTTIMEFORMAT="%Y%m%d-%H%M%S:"
export HISTTIMEFORMAT
export PROMPT_COMMAND=‘{ command=$(history 1 | { read x y; echo $y; });
logger -p local1.notice -t bash -i "user=$USER,ppid=$PPID,from=$SSH_CLIENT,pwd=$PWD,command:$command"; }‘
添加完之后,重新加载该文件 source /etc/profile
这样在/var/log/message中会记录用户的shell命令