On Linux, a history of recent console commands is stored in the .bash_history file. You can view the contents of this file with any text editor or with the command:
The command will output a numbered list of all the commands you have previously run. For convenience, you can add the timestamp (date and time) of the command execution to the bash history.
To do this, you need to add the following parameters to the ~/.bashrc file.
$ mcedit $HOME/.bashrc
export HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S '
$ echo 'export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S "' >> ~/.bash_profile
Additionally, you can increase the size of the .bash_history file to 2000 lines:
A list of commands that do not need to be saved to the bash history can be added to the histignore list:
To apply the changes, you need to re-login or run the command:
$ source ~/.bashrc
The date and time will now be displayed opposite the command in the bash history.