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

空扰寡人 提交于 2019-12-01 07:20:52

[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 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!