Start bash session without history

There are several options to disable saving commands to bash history e.g.

set +o history

or

unset HISTFILE

How to start a new bash session with history disabled?

I tried bash +o history but it didn’t work.

EDIT: I don’t want to modify my rc or profile files. I just want to start a single bash session with a different configuration.

Asked By: timakro

||

If you want to permanently disable history you can add shopt -u -o history or set +o history to your ~/.bashrc, or /etc/profile. Then clear your history!

history -c
Answered By: Hunter.S.Thompson

Add the set +o history option in:

~/.bashrc

(it might change depending on the distro)

Then clear the history with:

history -c

Log off and log on again.

Answered By: Adonist
bash --init-file <(echo '. ~/.bashrc; unset HISTFILE')

OR

bash --rcfile <(echo '. ~/.bashrc; unset HISTFILE')

And better put it in ~/.bash_aliases as permanent alias:

alias bash2="bash --init-file <(echo '. ~/.bashrc; unset HISTFILE')"
Answered By: 林果皞

The simplest solution was posted in a comment, which I think should be one of the answers here

Execute this command to start a bash shell that does not save any commands to history :

HISTFILE= bash
Answered By: madacoda
export HISTFILE=

And commands in that session will not be saved. Commands in other terminal windows or sessions will still be saved as usual.

Answered By: Carolus
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.