给Linux的history日志 添加时间戳和用户名

在linux日常使用中,可以方便查看history中的哪个用户什么时间发的什么命令。

在 /etc/profile 中 添加

export HISTTIMEFORMAT="%F %T `whoami` "

效果:

1086 2017-07-24 18:51:23 root history

1087 2017-07-24 18:51:59 root vim /etc/profile

1088 2017-07-24 18:52:28 root source /etc/profile

1089 2017-07-24 18:52:31 root history

1090 2017-07-24 18:52:42 root vim /etc/profile

1091 2017-07-24 18:52:55 root source /etc/profile

1092 2017-07-24 18:52:58 root history