Add time and date (timestamp) to the history on Linux

Add time and date (timestamp) to the history on Linux

I have no idea why this feature is missing from any (?) Linux distribution, but it's time to fix it. It can be useful in some cases.

It works on any Linux distribution. Just run these commands and check the history:

echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
source ~/.bash_profile

Amazing, right?

Bonus trick: check the ID of any command on the left side of the history output. Press !1000 (if the ID is 1000). This will re-run the command. It's much easier than typing the command again, or copying and pasting it.

Click here for more Linux articles.

Comments