Adding the time stamp to the History Command

The History command does not output the time stamp with the log of the most recently executed commands.

To Display Date and Time:

To do so, run the following command in the terminal:

Please note that there is a space before the last double-quotes.

If you want to permanently append this changes, add the following line to the ~/.bashrc file:


Run the command, it will be adding ~/.bashrc file

Then, from the terminal, run the following:

Now, to see history, type:

Sample outputs:

To Display dd-MON-YY & AM/PM & Timezone:

Sample Outputs:

Here’s an explanation of the commands and switches:

Commands Explanation
history GNU History Library
HISTTIMEFORMAT Environmental Variable
%d The day of the month as a decimal number (range 01 to 31)
%m The month as a decimal number (range 01 to 12)
%y The year as a decimal number without a century (range 00 to 99)
%T The time in 24-hour notation (%H:%M:%S)
%r The time in a.m. or p.m. notation. In the POSIX locale, this is equivalent to %I:%M:%S %p
%Z The timezone name or abbreviation
source In short, send the contents of the file to the shell
.bashrc Is a shell script that BASH runs whenever it is started interactively


For more info type the following commands:

Vijayan J

Thanks for stopping by guys! I’m Vijayan and Techpulse is my beloved brainchild.
Currently working as a PHP developer in a digital marketing start-up, I’m overly passionate about not just learning new things but also putting those into practice. I swear by a quote I once came across…
‘What separates successful people from unsuccessful people is the former’s ability to execute’.
Feel free to reach out to me if you have any questions, suggestions or feedback. Hoping to see more of you here!