You may want to clear the history file and the screen for the
security reason. Some Linux distributions may clear the screen but
others do not clear the screen when you logout. Many programs read input
as a single line at a time. The GNU history library is able to keep
track of those lines, associate arbitrary data with each line, and
utilize information from previous lines in composing new ones. Bash and
other shell may use this history library.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