To disable a history in Linux environment I've executed the following commands:
export HISTFILESIZE=0
export HISTSIZE=0
unset HISTFILE
Is such command combination enough or I have to also execute history -c
or something else?
Will this keep history disabled even when I reboot a server or such commands need to be executed after reboot again and again?
Just add this command to a bash startup file which could be
/etc/profile
,~/.bash_profile
,~/.bash_login
,~/.profile
, or~/.bashrc
depending your target scope and distro that customizes bash. See theINVOCATION
section of bash's manual (man bash
).Or
Which would disable history.
Although you have to clear your history once:
And also delete your
~/.bash_history
file.If you want it to persist through reboots, you can add them to
~/.bashrc
or/etc/profile
.For most usecases,
unset HISTFILE
should be enough.That disables writing the history file, while it still allows to cycle through the last commands using up/down.
Changing
HISTFILESIZE
doesn't have any effect when you unsetHISTFILE
, as it only affects how many lines will be written to the history file when the shell exits. If set to 0 withHISTFILE
set, then the file will be truncated to 0 at exit.Changing
HISTSIZE
changes how many commands the current shell will remember.To make this changes permanent,
~/.bashrc
or~/.profile
are good places to insert the commands.