To display shell command history with date and time under a Linux,
1.Defining the environment variable named HISTTIMEFORMAT as follows:
$ HISTTIMEFORMAT="%d/%m/%y %T "
Where,
%d – Day, %m – Month, %y – Year, %T – Time
2. Use the source command to load HISTTIMEFORMAT from the file into the current shell script or a command prompt:
$ . ~/.bash_profile_file
Sample Output:$ history
519 05/08/17 16:43:41 history
520 05/08/17 16:43:53 w
521 05/08/17 16:43:56 iostat
522 05/08/17 16:44:01 top
523 05/08/17 16:44:07 at
524 05/08/17 16:44:09 q
525 05/08/17 16:44:20 history