Turn off history on bash and sh shells

Is there any way, can turn off history permanently for the following shells on the RHEL 7 platform.


  1. yes, you need to add the following to your ~/.bash_profile file:
set +o history
  1. Save and close the file.
  2. Delete it existing from the shell, run:
    history -c
  3. Log out
  4. Test it.

For more info read:


This setting not working for “sh” shell …

/bin/sh is nothing but bash shell itself on RHEL 7. So it should work. You can verify symlink with the following command:

ls -l /bin/sh
ls -l /bin/{sh,bash}
-rwxr-xr-x. 1 root root 964608 Oct 30 22:37 /bin/bash
lrwxrwxrwx. 1 root root      4 Dec  5 06:53 /bin/sh -> bash

Also only v8 of Unix sh has history feature defined by HISTORY variable. So try to unset in $HOME/.profile.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki