Enable date-stamp in your .bash_history file

Linux specific questions/information are gathered here. The main thrust of topics are applied to Centos/RedHat(RH)/Debian/Ubuntu/Gentoo distributives

Enable date-stamp in your .bash_history file

Postby lik » Sat Aug 15, 2009 11:07 pm

Enable date-stamp in your .bash_history file

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

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.
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to Linux specific


  • Related topics
    Last post