> ## Content Index
> Fetch the complete content index at: https://linuxhandbook.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Enable Timestamp in History Command in Linux
- URL: https://linuxhandbook.com/history-command-timestamp/
- Published: 2022-11-22T10:37:59.000Z
- Updated: 2022-11-22T10:37:59.000Z
- Description: You can easily see which commands you ran in the past. But do you know when did you run it? The history command can tell you that as well.
- Author: Sagar Sharma
- Tags: Tips

You are familiar with the [history command in Linux](https://linuxhandbook.com/history-command/). It lets you see which commands you ran in the past.

But there is one issue. By default, the history command does not show when the command was executed (with date and time).

This could be helpful in some cases to know the time when a certain command was executed last.

And in this quick tip, I will show you how you can enable timestamps in the history command.

## Enable timestamp in history command 

To enable timestamps in the history command, you have to export the `HISTTIMEFORMAT` [environment variable](https://linuxhandbook.com/print-environment-variables/). 

[Use the export command](https://linuxhandbook.com/export-command/) like this:

```
export HISTTIMEFORMAT="%F %T "
```

Here,

- `%F` will show the date in YYYY-MM-DD format.
- `%T` will show time in HH:MM:SS format.

The modifications should now be reflected when you use the history command again:

![enable timestamp in history command](https://linuxhandbook.com/content/images/2022/11/enable-timestamp-in-history-command.png)

History now shows the timestamps of the commands

However, as the modifications are only effective during the current session, the history command will return to its previous appearance after a reboot.

And if you want to apply timestamp permanently, here's how you do it.

### Enable history timestamp permanently 

To have a timestamp in the history command permanently, you'll have to make changes in `.bashrc` file. 

Yes, no surprises there. If you want to make an environment variable permanent, it goes in your bashrc. 

Open the `.bashrc` file in your favorite text editor. I am using Nano here.

```
nano ~/.bashrc
```

You can use `Alt + /` to jump to the end of the file in Nano and add the following line:

```
export HISTTIMEFORMAT="%F %T "
```

![enable timestamp in history command permanently](https://linuxhandbook.com/content/images/2022/11/enable-timestamp-in-history-command-permenently.png)

[Save the changes and exit nano](https://linuxhandbook.com/nano-save-exit/). 

Now, to take those changes into effect, you will have to source the `.bashrc` file [using the source command](https://linuxhandbook.com/source-command/): 

```
source ~/.bashrc
```

And now, whenever you will use the history command, it will show the timestamps with every command. 

## Wrapping Up

This was a quick tutorial on how you can enable timestamps in the history command. I hope you find this [quick history command tip](https://linuxhandbook.com/bash-history-tips/) helpful in your Linux journey. Here are a few more.

[5 Simple Bash History Tricks Every Linux User Should KnowEffectively using bash history will save you plenty of time in the Linux terminal.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/2021/07/Bash-history-tips.png)](https://linuxhandbook.com/bash-history-tips/)

Do leave a comment if you have any doubts or suggestions.