Quit Bash Shell without Saving Bash History

From Brian Nelson Ramblings
Jump to: navigation, search

Remove Only Current Session Bash History

You will sometimes come across instances where you do not want to leave a bash history of your current session.

Example reason, you are on a clients account and you do NOT want them to see what commands you ran on their account.

1) Quit Bash Shell without Saving your History: Unset HISTFILE

unset HISTFILE && exit

2) Quit Bash by Killing your Current Console: Kill Console

kill -9 $$

3) Set your Bash Shell history to Zero(0): Set HISTSIZE 0

HISTSIZE=0 && exit

4) Clear History Option: Clear History(my fav)

history -c && exit

5) Delete your HISTFILE and unset HISTFILE : Quit Bash

rm -f $HISTFILE && unset HISTFILE && exit

Creat an alias to Accomplish this task

echo "alias nohistory='history -c && exit'" >> ~/.bashrc