Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to temporarily suspend history tracking in bash, so as to enter a sort of "incognito" mode? I'm entering stuff into my terminal that I don't want recorded, sensitive financial info.

share|improve this question
up vote 38 down vote accepted

This should be what you're looking for:


From man bash

If HISTFILE is unset, or if the history file is unwritable, the history is not saved.

Alternatively, if you want to toggle it off and then back on again, it may be easier to do:

Turn Off

set +o history

Turn on

set -o history
share|improve this answer
The value of HISTFILE is only checked when bash exits, so the first method doesn't work as is (if you restore the value, the command will be saved). set +o history does work as directed. – Gilles Apr 8 '11 at 20:10
Thanks, excellent. I'll use set +o history and set -o history to toggle back and forth when I'm doing secret stuff ;) – Naftuli Tzvi Kay Apr 8 '11 at 23:38
unset HISTFILE does not work. set -/+o history works like a charm! thanks – kholofelo Maloma Oct 28 '15 at 13:10

Using bash, set HISTCONTROL="ignorespace" and precede with space any command you do not wish to be recorded in history. In case you forgot to take any measures, there is also history -d <number> for deleting a specific entry or history -c for clearing the entire command history.

share|improve this answer

Make sure that HISTCONTROL contains ignorespace. You'll probably want to add HISTCONTROL=ignorespace (or HISTCONTROL=ignoredups:ignorespace or something) to your ~/.bashrc. Then any command line that begins with a space is omitted from the history.

Another possibility is to start a new bash session that doesn't save its history.

$ bash
$ unset HISTFILE
$ sooper-sekret-command
$ exit
$ #back in the parent shell
share|improve this answer

There is one simple way to turn off the history, so commands won't be stored in the .bash_history file.

You have to put the whitespace or tab space in front of any command, so that command won't be stored in the history. For example:

$ ls 
print the list of file 
$ history 

$  pwd
print the current  working directory 
$ history 

The pwd command will not get store in the history, because it has whitespace in the front.

share|improve this answer
This does not work; Bash complains that '-' or '-history', or other hyphenated commands cannot be found. – Samuel A. Falvo II Nov 12 '15 at 21:52
This wont work unless HISTCONTROL="ignorespace" is set as in forcefsck's response – DeveloperChris Mar 21 at 23:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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