Add time and date to bash history

October 22, 2015 — Leave a comment

Don’t you wish that your bash history went a little longer? Also, time and date would be super handy! Follow this quick guide to add time and date to your bash history, as well as making it go back further by extending it to 5000 lines.

Before we go further.. this won’t magically add correct dates to old entries in your history, everything from the past will appear to have been done today. Going forward, however, you will see the exact time and date (according to the server) of when commands were run.

There are two ways to do this: globally or per user

Globally: edit /etc/bashrc (or /etc/bash.bashrc in ubuntu)
Per user: edit ~/.bashrc

Pick one, then add the following to the bottom of the file for adding time/date:

You’ll now see something like:

Now, stretch out that history file! Add the following to extend it to 5000 lines:

Now, it’ll keep growing to 5000 lines (up from 500).

No Comments

Be the first to start the conversation.

Leave a Reply