I like to know what’s happening on my Linux servers. The output of the history command doesn’t include a datetime stamp by default.  To rectify this open the global profile….

vi /etc/profile

Add the following line to the bottom.

export HISTTIMEFORMAT="%h %d %H:%M:%S "

The output of the history command will now look something like…

997 Jun 12 11:01:55 exit
  998 Jun 12 11:01:55 df -h
  999 Jun 07 18:02:28 history
 1000 Jun 07 18:02:37 exit
 1001 Jun 12 11:01:58 history
 1002 Jun 12 11:03:40 df -h
 1003 Jun 12 11:03:46 history

All current entries will be defaulted to the current timestamp so it will take a little time for the output to be valid. Tested on OpenSuSE 11.2 but should be valid for many other distributions.