History: display date/timestamp in front of each command

When you type the command “history” then Linux will return the previously runned commands and prefixes them with digits:

root@dev /root # history
1 command
2 command 2
3 command 3

If you want to see the date and timestamp instead of the enumeration then run:

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

Now re-login to the shell and from that moment every command will be recorded including date/timestamp. The next time when you run history it will show:

root@dev /root # history
2019-02-15 19:14:41 command
2019-02-15 19:15:41 command 2
2019-02-15 19:14:41 command 3

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp