While it’s easily cleared by a malicious person, this can easily extend the usefulness of your history file with the information of when you ran that command.
This works in bash v3 and up.
If you’d like to add the time-stamping to all users on the machine, the file you’d want to edit is probably /etc/profile. If not, add it to your .bash_profile in your home directory (~).
Add this to the end of '.bash_profile':
- Code: Select all
HISTTIMEFORMAT="%D %T "
To get your current session to use the new settings:
- Code: Select all
source /etc/profile
Check it out :
- Code: Select all
history | tail
I love bash, the more if the inbuilt features I learn, the more I realize how great it is.