show command time at history in centos 7

set in shell
> HISTTIMEFORMAT="%y/%m/%d %T "

show result
> history



20170606
-----------------
add setting in /etc/profile to take effect automatic.

version 1
----------
export HISTTIMEFORMAT="%F %T `whoami` "

note datetime and username

version 2
---------
USER_IP=$(who am i | awk '{print $NF}' | sed -e 's/[()]//g')
export HISTTIMEFORMAT="%F %T `whoami` ${USER_IP} "

note datetime and username and ip







留言

熱門文章