Add timestamps to Linux command history

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s