5

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.

1
  • @DopeGhoti bash: history: invalid shell option name, +O is for shopt – timakro Aug 9 '17 at 15:41
3
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')"
0

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
0

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.

2
  • I wrote the exact same thing couple minutes before you, why the repost? – Hunter.S.Thompson Aug 9 '17 at 15:47
  • Sorry dude, I probably had a couple of tabs opened and your reply wasn't there when I first opened it. – Adonist Aug 10 '17 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.