Do you need to learn or know how to clear the Terminal or Bash history on macOS? I notice that it tracks what was entered previously by myself or those sharing the system so when I am done in the Terminal, I enter the following.
rm ~/.bash_history; history -c
(Works in macOS Catalina and later.)
It is two lines of code that are separated by a semicolon to make it simple to execute.
What Happens
By using rm ~/.bash_history, it temporarily removes or deletes ~/.bash_history. Once you start to use the Terminal, it is recreated and produces an output when history is executed. To make sure no one knows you executed the remove command, you execute history -c as it clears the history for the current shell.
Required Permissions
If you are using an account that is placed in the automatic login field and is not given the password, you should know that sudo is not required.
Stephan Pringle
Latest posts by Stephan Pringle (see all)
- ADFS/CAS Time out - Thursday, September 19, 2024