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.
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
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.
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')"
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
export HISTFILE=
And commands in that session will not be saved. Commands in other terminal windows or sessions will still be saved as usual.