How to add timestamp in bash history in linux

The time stamp can be added to the bash history using the a system variable “HISTTIMEFORMAT”. Steps: Log into your server, then run: The above command will work temporary and after you logged out, it will be flushed. To make these changes permanent, use below commands: Once you changed the value of “HISTTIMEFORMAT” variable, you will see the current timing for all past commands. But the time will be displayed correctly for all commands thereafter. Below is the example: output of history command That’s it. Need help? checkout our plans.