Under normal circumstances, a command typed in a Terminal/shell can be retrieved later via history command or other means.

Is there any way to have an "incognito" Terminal/shell, i.e. one whose commands are not remembered in any way after it is closed?

One use for this would be to charge a credit card, or perform other security sensitive commands.

A potential answer is to boot a Linux "Live CD" and then shut it down. Any other (easier) approaches that would work in OS X/Linux/Windows?

1 Answer 1


You did not specify which shell you are using but:

The HISTFILE environment variable defines where the history is stored. With


you can tell bash to stop recording commands. You can re-enable it with

export HISTFILE=${HOME}/.bash_history

From man bash:

       The name of the file in which command history is saved (see  HISTORY  below).   The  default
       value  is  ~/.bash_history.   If unset, the command history is not saved when an interactive
       shell exits.
  • Is this the only file that keeps any history? If I delete something private from there, can I be sure it won't be anywhere else too? Sep 25, 2012 at 19:15
  • 1
    It is the only place where the shell stores the history but if something else (e.g., a backup program) copies the history file somewhere else you will have to delete it also there.
    – Matteo
    Sep 26, 2012 at 5:09
  • 1
    @Matteo This does not seem to be entirely true. In Mac OSX's Terminal, if I do: unset HISTFILE; sudo echo sensitive_command, then sudo grep -r "[s]ensitive_command" / ... I can see the command in /private/var/log/system.log. Apr 8, 2014 at 22:11
  • 2
    After a bit of testing, only successful sudo commands appear to be logged in /private/var/log/system.log (sudo commands only, even as root user). Apr 8, 2014 at 22:29

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.