
The default fie is ~/.history or ~/.bash_history.
History can be reset by appending following commands.
>~/.bash_historyFrom above listed commands first one will clear bash history and second one will clear mysql command history using redirection operator ‘>’.
>~/.mysql_history
I’m using CentOS Linux server and how do I clear bash history in UNIX / Linux / BSD operating systems?
You can set another option to clear the history. Set the link ~/.bash_history to /dev/null:
#ln -sf /dev/null ~/.bash_historyYou can also use history command to clear histroy.The -c option causes the history list to be cleared by deleting all of the entries.
$ history -cThe option –d is also used to clear history.This will delete the history entry at position offset.
# history -d offsetExample
# historyNow if you want to delete the mkdir command just use:
1 cd
2 history
3 ls -alhF
4 history
5 wget username:password@private.ftp.com/secret/file.tar.gz
6 mkdir
# history -d 5
# history
1 cd
2 history
3 ls -alhF
4 history
5 wget username:password@private.ftp.com/secret/file.tar.gz
6 history
7 history –d 6
Stop writing to .bash_history
You can stop logging of history using one of the two ways: turn it off for all users, or turn off logging history for a single user.Turn off bash history for all users
# echo “unset HISTFILE” >> /etc/profile
Turn off bash history for a specific user
# echo “unset HISTFILE” >> /home/USER/.bash_profile
Anther method is set below parameters to zero.
You can edit your .bashrc and addHISTFILESIZE=0Now you can successfully delete the bash history and even stopped logging to bash history using any of the above listed commands.
HISTSIZE=0
Disqus comments