Showing command history in UNIX with timestamps

A handy little command for checking the history of all commands executed through the UNIX command prompt for that user.

history

This will return you a numbered list of commands, oldest first.

Note that by default, “history” will NOT show you timestamps, which can be very handy if investigating activity on a certain machine.

To show history with timestamps, you’ll need to set up an evironment variable to store the format that history should be output in. Simply execute the following command.

export HISTTIMEFORMAT='%F %T '

Any subsequent call to history will show you the date and time.

Leave a Reply

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