This comes in very handy if your trying to track back when you had last run something.
To enable it just simply add export HISTTIMEFORMAT="%h/%d - %H:%M:%S " to your .bashrc file
echo 'export HISTTIMEFORMAT="%h/%d - %H:%M:%S "' >> ~/.bashrc
Then reload your .bashrc
source ~/.bashrc
Now when you run history you should get a output similar to the one below
502 Aug/12 - 13:48:31 tail -f /home/duffy/log/access.log 503 Aug/12 - 13:49:01 echo hello 504 Aug/12 - 13:49:24 more /var/log/syslog
Some other bash history tips
- The best way of finding something quickly in your bash history is simply by pressing ctrl+r and then typing out the start of the command it will auto complete it with any matches found in your bash history
- If you don't want to save duplicate commands in your bash history simply add export HISTCONTROL=ignoreboth to your .bashrc
echo 'export HISTCONTROL=ignoreboth' >> ~/.bashrc
- If you want to change the lenght of history add export HISTSIZE=1000 to your .bashrc
echo 'export HISTSIZE=1000' >> ~/.bashrc


Wed, Aug 12, 2009
Misc