If I run `history`, I can see my latest executed commands.

But if I do `tail -f $HISTFILE` or `tail -f ~/.bash_history`, they do not get listed.

Does the file get locked, is there a temporary location or something similar?
['https://unix.stackexchange.com/questions/145250', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/57143/']
(Not an answer but I cannot add comments)

If you are checking `.bash_history` because you just want delete a specific command (e.g. containing a password in clear), you can directly delete the entry in memory by `history -d <entry_id>`.

For example, supposing an output like:

```
$ history
926  ll
927  cd ..
928  export --password=super_secret
929  ll

```

and you want purge the `export` line, you can simply achieve it by:

```
history -d 928

```
bash keeps it in working memory, bash can be configured to save it when bash closes or after each command, and to be loaded when bash starts or on request.

If you configure to save after each command, then consider the implications of having multiple bash running at same time. (command lines will be interleaved)