Linux开启同步history记录到指定文件

[root@node1 tmp]# vi /etc/profile

export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });echo  "[euid=$(whoami)]":$(who am i):[`pwd`]#"$msg" >>/tmp/history_cmd.log; }'

[root@node1 tmp]# .  /etc/profile

[root@node1 tmp]# chmod 777  history_cmd.log 

[root@node1 tmp]# chattr  +a  history_cmd.log 

posted @ 2019-10-13 20:10  shangshanyang  阅读(1180)  评论(0编辑  收藏  举报