Leave no traces in your .bash_history file

By | February 4, 2011

If you wish to not leave traces of your CLI activity in the .bash_history file, you can exclude the logging of certain commands by appending a space character before them. For example, press the space bar before you type cat /etc/passwd:

<space>cat /etc/passwd

6 thoughts on “Leave no traces in your .bash_history file

  1. nobody

    If you’ve already done everything you want to and you don’t want to save your history, you can also type:

    kill -9 $$

    to kill bash, and it won’t save any history from that login session.

    Reply
  2. greg

    so the space prefix preventing the saving of the line only works if you enable ‘ignorespace’ option in the HISTCONTROL environmental variable for the bash shell. check out the man page for bash.

    Reply
  3. NixTrix

    That’s a tweak in .bash_history and you may have to remember inserting every time if you dont want list of commands listed out in the history later.

    Easiest way is to run “history -r” after you are done, as it will erase your current session history.

    “history -c” would erase entire history which is not required in case you only want to clean your own footsteps.

    Reply
  4. maxxemm

    unset HISTFILE
    will not save history of the current session after exiting the session. After logging in again, everything comes back to normal.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *