Linux - Clear Bash History
Published: Linux Estimated reading time: ~1 minutes
Bash history is stored in ~/.bash_history
. When you log out of the current shell, the shell’s history is written to the hidden file.
To empty out history, first clear the history from the current session
# history --help
# -c clear the history list by deleting all of the entries
history -c
Then write the current history to the file
# -w write the current history to the history file
history -w
Now if you look at the contents of ~/.bash_history
, it will be empty, and no commands are available by pushing the up arrow.
cat ~/.bash_history
Combine it all together
history -c && history -w