How can I run a shell command without being added in history? I don't want to purge the command history, I just don't want my next shell command doesn't show up in the history. Is this possible?
bash, to prevent a command from being added to history, put a space before the command. This is assumes that you have, as is common, the
ignorespace option set in
HISTCONTROL. If you don't, run the following command (or add it to
~/.bashrc to make it permanent):
Many people also want to ignore duplicate commands, in which case use:
If you want to ignore certain commands always, then use
HISTIGNORE. For example, the following setting will always ignore
sudo shutdown followed by any options, and
export HISTIGNORE="sudo poweroff:sudo shutdown*:sudo reboot"