Last Updated: February 25, 2016
·
856
· sdepablos

Add date & time to your bash history

Sometimes you need to know when a command was executed in shell, but by default history does not show it. To enable it, just edit /etc/bashrc (global) o ~/.bashrc (per user) and add

HISTTIMEFORMAT="%h %d %H:%M:%S "

To improve the history even more, we could avoid having duplicates lines in the history:

HISTCONTROL=ignoredups:ignorespace

avoid overwriting the history file

shopt -s histappend

and setting a bigger history length

HISTSIZE=100000
HISTFILESIZE=200000