Kamis, 17 Januari 2019

Quit Bash Shell Without Saving Bash History


Sometimes it is very useful to delete / remove Bash history partially or completely when log out. Here is my favourite methods howto log out / quit / exit Bash shell without saving Bash history.

Remove Only Current Session Bash History and Leave Older History Untouched

  1. Quit Bash Shell Without Saving History: Unset HISTFILE

  2. # unset HISTFILE && exit

  3. Quit Bash by Killing you Current Consolel Without Saving History: Kill Console

  4. # kill -9 $$

  5. Quit Bash Shell Without Saving History: Clear History Option

  6. #history -c && exit

  7. Set your Bash Shelll history to Zero(0):  Set HISTSIZE 0

  8. #HISTSIZE=0 && exit


Remove/Delete Bash History Completely

  1. Quit Bash Shell Without Saving History: Delete HISTFILE and Unset HISTFILE

  2. #rm -f $HISTFILE && unset HISTFILE && exit


If you want make these commands more permanent then these commands could be added on ~/.bash_logout file or used with aliases.

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


Tidak ada komentar: