linux主机history日志输出时间、用户、IP、执行指令
history 10
echo ‘export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S,whoami
,who am i 2>/dev/null| \awk '"'{print \$NF}'"'|sed -e '"'s/[()]//g'"'
,"’ >> /etc/profile
cat /etc/profile | grep “export HISTTIMEFORMAT=”
source /etc/profile
history 10
输出结果:
523 2021-04-01 23:23:43,root,111.112.111.222,cat /etc/profile