Linux users to log and record operations

[root@i-07mge009 ~]# touch /var/log/Command_history.log
[root@i-07mge009 ~]# chown nobody.nobody /var/log/Command_history.log
[root@i-07mge009 ~]# chmod 002 /var/log/Command_history.log
[root@i-07mge009 ~]# chattr +a /var/log/Command_history.log
[root@i-07mge009 ~]#vim /etc/profile
export HISTORY_FILE=/var/log/Command_history.log
export PROMPT_COMMAND='{ date "+%Y-%m-%d %T ##### USER:$USER IP:$SSH_CLIENT PS:$SSH_TTY ppid=$PPID pwd=$PWD  #### $(history 1 | { read x cmd; echo "$cmd"; })";} >>$HISTORY_FILE'

#使配置生效
source  /etc/profile

Guess you like

Origin blog.51cto.com/hsuing/2415673