How to see time stamps in bash history?
Press Ctrl+Alt+T to open a terminal, then run one of the commands below:
HISTTIMEFORMAT="%d/%m/%y %T " # for e.g. “29/02/99 23:59:59”
HISTTIMEFORMAT="%F %T " # for e.g. “1999-02-29 23:59:59”
To make the change permanent for the current user run:
echo 'HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bashrc # or respectively
echo 'HISTTIMEFORMAT="%F %T "' >> ~/.bashrc
source ~/.bashrc
To test the effects run:
history
For more info see man bash or An A-Z Index of the Bash command line for Linux.
For commands that were run before HISTTIMEFORMAT
was set, the current time will be saved as the timestamp. Commands run after HISTTIMEFORMAT
was set will have the proper timestamp saved.
Open terminalCtrl+Alt+T and run,
HISTTIMEFORMAT="%d/%m/%y %T "
then,
history
To make the changes permanent follow the below steps,
gedit ~/.bashrc
you need to add the below line to .bashrc file and then save it,
export HISTTIMEFORMAT="%d/%m/%y %T "
run the below command to source .bashrc file,
source ~/.bashrc
After that run history
command.
source:http://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/
Yes, you can: if you set $HISTTIMEFORMAT
, the .bash-history
will be properly timestamped. That doesn't help with existing .bash-history
content, but will help in the future.