标签:format awk source his root 时间 whoami roo who
修改/etc/profile
增加
export HISTTIMEFORMAT="%Y%m%d_%T `whoami` `who am i|awk ‘{print $1,$5}‘|sed ‘s/ (/@/‘|sed ‘s/)//‘` "
export PROMPT_COMMAND=‘history 1|{ read x y; echo $y; } >> /var/log/.history/${LOGNAME}.history‘
之后
mkdir /var/log/.history
source /etc/profile
即可
效果:
1003 20191227_10:01:45 root root@1.2.3.4 history
1004 20191227_10:01:57 root root@1.2.3.4 source /etc/profile
1005 20191227_10:02:13 root root@1.2.3.4 mkdir /var/log/.history
1006 20191227_10:02:19 root root@1.2.3.4 source /etc/profile
1007 20191227_10:02:22 root root@1.2.3.4 history
标签:format awk source his root 时间 whoami roo who
原文地址:https://www.cnblogs.com/zepc007/p/12113461.html