The key to problem is HISTCONTROL variable. HISTCONTROL is an environment variable which is set by default in almost every Linux distribution.If you do not wish to log the commands you are executing, start your command with space; this way it wont be included in history.
But, this will only work when your HISTCONTROL variable is set to
ignoreboth. To check current value for HISTCONTROL :
$ echo $HISTCONTROLand, to set HISTCONTROL for a terminal session :
$ export HISTCONTROL=some-valueand, to set HISTCONTROL to some value for every terminal session, find/add HISTCONTROL variable in
~/.bashrcfile, and set it to some value.
HISTCONTROL variable can have three values;
ignoredups : When set to this value, you can ignore duplicate commands from entring your .bash_history file.
ignorespace : When set to this value, you can ignore commands starting with a space from entring your
ignoreboth : When set to this value, you can ignore duplicate commands from entring your .bash_history file as well as the ones starting with a space. In short,
ignoreboth acts like