Thursday, January 31, 2019

The shell variable HISTTIMEFORMAT and the "history" command



If you need to investigate the history of commands on your linux/Unix server, set the HISTTIMEFORMAT parameter first:
HISTTIMEFORMAT="%d/%m/%y %T " 

After that, you'll find a much more precis listing of your history:

  962  31/01/19 11:08:50 cd product/
  963  31/01/19 11:08:50 ls -al
  964  31/01/19 11:08:50 du -sh *
  965  31/01/19 11:08:50 cd ..

instead of
  962  cd product/
  963  ls -al
  964  du -sh *
  965  cd ..
The man page for history states

If the HISTTIMEFORMAT variable is set, the time stamp information associated with each history entry is written to the history file, marked with the history comment character.

No comments:

Post a Comment