The linux history command is a great way to review which commands you’ve used on your machine in the past. Unfortunately there is no information on when the commands were executed. Sometimes knowing when is important too.
Fortunately it’s easy to enable timestamps as part of the command history:
- Edit /etc/profile
- Add the following line at the bottom of the file:
export HISTTIMEFORMAT="%F %T "
- Save and exit
That’s it! The next time you login your command history will include timestamps. If you don’t want to wait, run the source command to reload the profile information:
source /etc/profile