The Bash history feature is an invaluable tool which allows users to recall commands previously entered into their shell with relative ease. This makes it easy to enter repeated commands and keep track of what was done on a system. By default, however, a user is unable to see whenthese commands were actually entered. When auditing a system, it can sometimes be useful to see this type of information, for example when trying to determine how and when a file may have gone missing on the file system. Since Bash version 3, however, you are able to enable time-stamping of entries for review later.
Applicable versions of Bash provide the environment variable HISTTIMEFORMAT which you can set for this purpose. Although it is empty by default, you can simple assign a time format string to enable time-stamping.
Enable timestamp in bash history
To enable time stamp on your bash history type following command on your terminal:
$ export HISTTIMEFORMAT="%F %T "
It will print the command line history with corresponding timestamp when the command was executed.
$ # history 1 2015-12-12 15:14:15 nmtui 2 2015-12-12 15:14:15 ping 18.104.22.168 3 2015-12-12 15:32:24 export HISTTIMEFORMAT="%F %T " 4 2015-12-12 15:32:26 history
That is it!