How to disable and clear Linux Command Line history
When you type commands in the bash shell, the shell by default is recording every command that you input via the terminal.
You can see the previously entered commands by using the up and down arrows on your keyboard or you can see a list of all the previously entered commands by issuing the history command. For example:
# history 1 man rmdir 2 cd /tmp 3 mkdir dir01 4 cd dir01 5 touch file01
The command history poses a privacy and security risk. You can clear the command history by using the “history -c” command. The command history is stored in ~/.bash_history file so removing that file will also clear the history. As per man page of history command:
# man history ... -c Clear the history list by deleting all the entries.
If you want to permanently disable history logging in Linux than you can setup the HISTSIZE variable to zero in /etc/profile. HISTSIZE i.e. the history size controls the number of entries which are stored in the command history buffer, so setting this to zero will just disable the terminal command history. For example:
# vi /etc/profile HISTSIZE=0