Tuesday, December 6, 2011

History command


Use inbuilt variable HISTTIMEFORMAT to set the values as shown below
#export HISTTIMEFORMAT='%F %T '
%F for setting year/month/day
%T for setting time
now try to execute history command to see the difference
#history
sample output
500  2011-03-16 17:06:09 exit
 501  2011-03-16 17:06:14 apt-get install tree
 502  2011-03-16 17:06:36 tree 
 503  2011-03-16 17:06:54 man tree
 504  2011-03-16 17:07:02 tree -d
 505  2011-03-16 17:07:07 tree 
If you restart/logout from machine will this setting available to you?
A simple answer for this is no. Then how can we make it permanent?
Just append this variable to .bash_profile for every user.
echo "export HISTTIMEFORMAT='%F %T '" >> ~/.bash_profile
How about setting this value to the new user which are going to be created on the machine?
export it to /etc/profile file
echo "export HISTTIMEFORMAT='%F %T '" >> /etc/profile

No comments:

Post a Comment