Clear all safari data using terminal

bowie
New Contributor III

I need to make a script that will clear all safari data, I found some commands that mostly work but I can't get rid of one thing saved microsoft account during SSO login, the only way that works is to delete safari history via GUI, but i need to do it using CLI.

Commands I've tried so far

osascript -e 'quit app "Safari"'
rm -Rf /Users/$3/Library/Cookies/*;
rm -Rf /Users/$3/Library/Cache/*;
rm -Rf /Users/$3/Library/Safari/*;

rm -Rf /Users/$3/Library/Caches/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery
rm -Rf /Users/$3/Library/Caches/Metadata/Safari
rm -Rf /Users/$3/Library/Caches/com.apple.Safari
rm -Rf /Users/$3/Library/Caches/com.apple.WebKit.PluginProcess
rm -Rf /Users/$3/Library/Cookies/Cookies.binarycookies
rm -Rf /Users/$3/Library/Preferences/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery
rm -Rf /Users/$3/Library/Preferences/com.apple.Safari.LSSharedFileList.plist
rm -Rf /Users/$3/Library/Preferences/com.apple.Safari.RSS.plist
rm -Rf /Users/$3/Library/Preferences/com.apple.Safari.plist
rm -Rf /Users/$3/Library/Preferences/com.apple.WebFoundation.plist
rm -Rf /Users/$3/Library/Preferences/com.apple.WebKit.PluginHost.plist
rm -Rf /Users/$3/Library/Preferences/com.apple.WebKit.PluginProcess.plist
rm -Rf /Users/$3/Library/PubSub/Database
rm -Rf /Users/$3/Library/Saved\ Application\ State/com.apple.Safari.savedState

 

Screenshot 2023-07-11 at 11.10.25 AM.pngScreenshot 2023-07-11 at 11.10.16 AM.png

 

 

 

3 REPLIES 3

AJPinto
Honored Contributor III

Have you tried clearing Kerberos tickets?

bowie
New Contributor III

I have never heard about this before.

AJPinto
Honored Contributor III

Try running kdestroy in terminal. Kerberos tickets are one of the methods that are used to pass around identities.

 

https://uit.stanford.edu/service/ess/mac/docs/kerberos_macOS