.bash_history modification

Hi Experts,

I know my question would be strange but i need to understand how the .bash_history file is logging user actions (the mechanism) and if possible modify it to include also the date/time of every action done by the user.

Sample file:

# more .bash_history
ssh <IP address> -l axadmin
cd /cygdrive/d/
ls
pwd
ls -ltr
exit
pwd
cd src/
ls
exit

Thanks in advance

See "HISTTIMEFORMAT" in man bash . It takes a string like strftime expects. HISTTIMEFORMAT="%F %T" should add lines to the history file like

# YYYY-MM-DD HH:MM:SS
historyline
# YYYY-MM-DD HH:MM:SS
nexthistoryline

Thanks for your quick reply, in fact i followed the below commands but it is giving effect only with #history command but it didn't modify the .bash_history file. Any comments?

#export HISTTIMEFORMAT='%F %T '
#history

.bash_history isn't updated at all until you quit your shell.

1 Like