history命令添加日志和用户

echo 'export HISTTIMEFORMAT="%F %T `whoami` "' >> /etc/profile

source /etc/profile

查询如下:

 578  2020-03-29 19:08:14 root whoami
  579  2020-03-29 19:13:31 root history
  580  2020-03-29 19:15:18 root vim /etc/profile
  581  2020-03-29 19:16:00 root source /etc/profile
  582  2020-03-29 19:16:04 root ls
  583  2020-03-29 19:16:06 root ll
  584  2020-03-29 19:16:10 root history
  585  2020-03-29 19:16:33 root  vim /etc/profile
  586  2020-03-29 19:19:55 root passwd st
  587  2020-03-29 19:20:05 root useradd st
  588  2020-03-29 19:20:10 root passwd st
  589  2020-03-29 19:21:20 root history
  590  2020-03-29 19:22:06 root reboot
  591  2020-03-29 19:23:00 root history
  592  2020-03-29 19:23:08 root su - st
  593  2020-03-29 19:23:23 root history
[root@iZ1la3d1xbmukrZ ~]#
原文地址:https://www.cnblogs.com/dalianpai/p/12594206.html