Linux用户进行登录及操作进行记录

[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

猜你喜欢

转载自blog.51cto.com/hsuing/2415673