Add date and time to history command in Linux system

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

Insert picture description here

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

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_39599464/article/details/114523660