How To

Configure history to show the time and date

Normally by default, your history will show just the number of the command that was run and the command.

[email protected] [~]# history | head
10 top
11 df -h
12 hostname -i

There are many times that you will want the time and date as well though, such as for server auditing and security reasons. To enable this, you will need to export HISTTIMEFORMAT.

[email protected] [~]# export HISTTIMEFORMAT=’%F %T ‘

This will enable the time stamps as well in your history. Now, when you run the history command, you will get something that looks like the following.

[email protected] [~]# history | head
10 2011-10-11 12:03:26 top
11 2011-10-11 12:03:29 df -h
12 2011-10-11 12:03:35 hostname -i

Let us know how you have your history set up in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *