Clear Terminal Cache [Duplicate]

Clear Terminal Cache [Duplicate]

I need to clear the terminal cache, I have tried with history -c but it clears the cache in that terminal session, but if I open another session and type history it shows all the previous commands.

0

2 Answers

See this question, with a few solutions if you are using bash as your shell. There are a few different options, depending on what you are trying to accomplish. There are some ways to clear it now, and ways to clear it on login or logout.

How to clear bash history completely?

Basically speaking, history -c clears it but you need to do a history -w to write the empty file to your ~/.bash_history.

Maybe this happened because you were running it from a terminal emulator, if you want to delete all your history (be wary), you can try to delete directly the file which log it:

rm ~/.bash_history
Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.