How to Remove/ Disable Bash shell Command History on Linux

This post will help you to remove/ disable Bash shell commands history on Linux.

1. Disable history for a current shell.

# set +o history

2. Clean command history.

# history -c

3. Permanently disable bash history.

# echo 'set +o history' >> ~/.bashrc

Next time when user login to the shell it will not store any commands to a history file .bash_history.

To apply this settings immediately for the current shell session execute the .bashrc file:

# . ~/.bashrc

4. Disable a command history system wide:

# echo 'set +o history' >> /etc/profile

It will be effective for the new users created after this.

Related Post