Thursday, September 13, 2012

See timestamp with Linux history command

You can see a recollection of commands on a linux system by using the history command. I would like to share with you a good trick to not only see the command, but also the timestamp it was executed. This is particularly useful for auditing. You simply need to set the environmental variable as follows:

export HISTTIMEFORMAT="%F %T "

Now, history will display commands as follows:

 1476  2012-09-13 06:25:59 mysql
 1477  2012-09-13 06:25:59 exit
 1478  2012-09-13 06:26:02 history | less

Post a Comment