让Linux的history命令显示用户名和时间
修改/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
即可
效果:
20191227_10:01:45 root history 20191227_10:01:57 root source /etc/profile 20191227_10:02:13 root mkdir /var/log/.history 20191227_10:02:19 root source /etc/profile 20191227_10:02:22 root history
相关推荐
renshuguo 2020-06-24
yuzhongdelei0 2020-06-13
Yyqingmofeige 2020-05-16
haohong 2020-04-08
tanyhuan 2020-03-01
kuwoyinlehe 2020-01-02
85407718 2019-12-06
81487308 2018-09-08
Aveiox 2018-06-11
80437700 2019-05-31
81427605 2019-05-21
89477009 2018-12-23
81487308 2019-09-04
84307063 2018-09-27
DBATips 2018-01-26
heroxsx 2013-02-23
zousongshan 2012-09-08
Andyshrk 2012-07-31
Kshine0 2012-07-17