We always check our History and Mostly for the work we have done. why do we save command history ? or what is the need to know when was it executed? the all questions are simple to answer. once you have install or edit something and now you need to again know how you did it then you just have to remember the time you did it and just See the command history you will get what you need.
To Check the time of the executed command, the environment variable for bash needs to be set as HISTTIMEFORMAT. After setting the variable you need to just execute the following command :
export HISTTIMEFORMAT="%F %T " |
Now, Check the history by executing the command below.
history |
This Command will show you the History in the following format (Just and Example) :
131 2011-02-25 19:28:22 /opt/lampp/lampp start 132 2011-02-25 19:28:22 sudo su 133 2011-02-25 19:28:22 sudo /etc/init.d/nscd restart 134 2011-02-25 19:28:22 sudo aptitude install nscd 135 2011-02-25 19:28:22 sudo apt-get install nscd 136 2011-02-25 19:28:22 sudo /etc/init.d/nscd restart 137 2011-02-25 19:28:22 sudo su 138 2011-02-25 19:28:22 service nscd remove 139 2011-02-25 19:28:22 service nscd status 140 2011-02-25 19:28:22 service nscd force-reload 141 2011-02-25 19:28:22 sudo service nscd force-reload 142 2011-02-25 19:28:22 service nscd status 143 2011-02-25 19:28:22 sudo service nscd start 144 2011-02-25 19:28:22 sudo su 145 2011-02-25 19:28:22 ping www.zerotech.in 146 2011-02-25 19:28:22 setip 147 2011-02-25 19:28:22 getip 148 2011-02-25 19:28:22 sudo su 149 2011-02-25 19:28:25 history 150 2011-02-25 19:28:53 export HISTTIMEFORMAT="%F %T " 151 2011-02-25 19:28:59 history |
Hope you like it , I would love to have your feedback
Sid says
Thanks a lot. Was searching for this option for so long.
Ritesh Sanap says
Thanks , its great that you got what you were looking for if you need anymore help then do say.