Upgrading history on Unix Systems
On unix systems, like Linux and MacOS, all commands are logged by default in order in which they were input. These logs can be accessed using the history
command. To see the time they were logged you can just use arguments such as -i
or -E
as displayed below, or you can permanently set an environment variable to include the date when you run history
history -i
history -E
# Only works for bash, for zsh you will need an alias
HISTTIMEFORMAT="%F %T "
echo "export HISTTIMEFORMAT=\"%F %T \"" >> ~/.bashrc
source ~/.bashrc
Links
Sources
- Bash History: How To Show A Timestamp (Date / Time) When Each Command Was Executed - Linux Uprising Blog
- How to view datetime stamp for history command in Zsh shell - Unix & Linux Stack Exchange