Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

4 Answers 4

up vote 14 down vote accepted

This should be what you're looking for:

unset HISTFILE

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
2  
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

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 .
If you put any command that is stored the .bash_history file 
In every command put the whitespace or tab space in front of the command 
That command can't store that history .For example 

$-ls 
print the list of file 
$-history 
ls
history

$-  pwd
print the current  working directory 
$-history 
ls
history

The pwd command will not get store in the history 
share|improve this answer

Your Answer

 
discard

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.