When I use a browser, I can "browse in private" if I don't want my browser history recorded on the local machine. But what if I'm typing commands in the bash shell and maybe passwords, and I don't want that stored in my command history, but at the same time I don't want to wipe out my command history? Is there a way to do that?
UPDATE: My answer was marked ACCEPTED before the question was marked as duplicate. The reference points out a solution possibly superior to the three I list below, depending on your use-case, so I'll repeat it here: Temporarily turn off history logging by typing
set +o history, and restore history logging by typing
set -o history.
bash, there are a few ways to manually create the environment you seem to want, all involving some combination of the internal
In the paragraphs below, quotations are verbatim from
1] You could start a shell with
HISTFILE unset, in which case "the command history is not saved when a shell exits".
2] You could manually set
HISTCONTROL to include the string
ignorespace, in which case "lines which begin with a space character are not saved in the history list.
3] You could manually set
*, or to something more specific, in which case lines matching your glob pattern(s) will not be saved. For this option, do read the
man page carefully, because there are several caveats and gotchas. That section of the
man page is short and clear, and its good practice to read it anyway, so I'm not cutting and pasting it here.