Friday, January 23, 2009
Typically when one type history command, it displays the command number and the command. For auditing purpose, it would be helpful to display the timepstamp along with the command. To do so we need to set the environmental variable HISTTIMEFORMAT.
HISTTIMEFORMAT supports format strings of strftime.
Some important format strings:
%T Replaced by the time ( %H : %M : %S )
%F Equivalent to %Y - %m - %d
Get the full list here
$ export HISTTIMEFORMAT='%F %T '
it will print the command line history with corresponding timestamp when the command was executed.
© Jadu Saikia www.UNIXCL.com