Enable Timestamp in Bash History
Instead of:
[fu@bar ~]$ history ... 990 nmap 10.9.6.0/24 991 history 992 less ~/.bash_history 993 ls -ltra 994 less ~/.lesshst 995 cd .config/ 996 ls -ltra 997 exit 998 ssh webserver 999 exit 1000 history
Do this:
[fu@bar ~]$ export HISTTIMEFORMAT="%F %T " [fu@bar ~]$ history ... 990 2022-11-23 20:29:44 nmap 10.9.6.0/24 991 2022-11-23 20:29:44 history 992 2022-11-23 20:29:44 less ~/.bash_history 993 2022-11-23 20:29:44 ls -ltra 994 2022-11-23 20:29:44 less ~/.lesshst 995 2022-11-23 20:29:44 cd .config/ 996 2022-11-23 20:29:44 ls -ltra 997 2022-11-23 20:29:44 exit 998 2022-11-23 20:29:44 ssh www7p.seei.biz 999 2022-11-23 20:29:44 exit 1000 2022-11-23 20:29:49 history 1001 2022-11-23 20:31:37 export HISTTIMEFORMAT="%F %T " 1002 2022-11-23 20:31:40 history
If you like it – instead of typing in the following every time
export HISTTIMEFORMAT="%F %T "
do this once:
echo 'export HISTTIMEFORMAT="%F %T "' >> ~/.bashrc exit
and every time you start a bash prompt, history will be formatted with the date and time.