Add a timestamp to the history command [Quick Guide]
The command ‘history’ allows to find a history of the orders entered by the current user. In general, it is very convenient in many cases.
Here is an example of the output of the command ‘history’ :
here we see something that is often lacking: the lack of timestamp. It is unclear when an order for been entered, neither the day nor the hour. It is information that we could find good useful
II. Add the time and date in the history of the orders
handling for this addition is relatively simple. Simply change the way commands are sent to the history. For this, we will change the initialization file of the shell user with the export of the following environment variable:
export HISTTIMEFORMAT = " % F % T: "
therefore add this entry in the file “ .bashrc ” to your user home. «» /root/.bashrc‘ for the user root and ‘/home/
Following this addition, think to relaunch a new session so that the environment variable is taken into account. You will then see the timestamp of your orders by running again the command ‘history’ :
Note that run the command ‘ export… ‘. “in the current shell will also work but the change will not be kept after a termination of your session