CentOS system
Add at the end of the file ~/.bash
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
vim ~/.bashrc
#末尾添加
export HISTTIMEFORMAT='%F %T '
Use the source command to make the file effective
source ~/.bashrc
Ubuntu system
Add at the end of the file /etc/bash.bashrc
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
vim /etc/bash.bashrc
#末尾添加
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "
Use the source command to make the file effective
source /etc/bash.bashrc