Guru Ji
asked on
Delete Browser data command line in MAC OS Sierra
I have a script .sh file which delete chrome data in iMAC and it works great.
How can I accomplish same for Firefox and Safari as I want all history and everything deleted and when current user opens firefox and safari it should open like a brand new one. Anyway to accomplish this via command line or script?
Thanks,
How can I accomplish same for Firefox and Safari as I want all history and everything deleted and when current user opens firefox and safari it should open like a brand new one. Anyway to accomplish this via command line or script?
Thanks,
It sounds like you want everything deleted. If you still want to script the deletion, you just need to remove the following profile directories and everythnig will be gone.
rm -rf ~/Library/Safari
rm -rf "~/Library/Application Support/Firefox/Profiles/* default"
rm -rf "~/Library/Application Support/Google/Chrome/Defa ult"
Would it be simpler to force them to always start in private mode? There would be less to delete.
https://www.askvg.com/how-to-always-start-your-favorite-web-browser-in-private-browsing-mode-by-default/
https://www.howtogeek.com/137466/how-to-always-start-any-browser-in-private-browsing-mode/
I haven't done this, but it would be in the Preferences files. You could change the settings to default open in Incognito or Private mode and copy the plist file to the user.
cd ~/Library/Preferences/
ls -l com.apple.Safari*
-rw------- 1 serialband staff 42 May 9 11:59 com.apple.Safari.Extension s.plist
-rw------- 1 serialband staff 2062 Mar 30 07:51 com.apple.Safari.Support.p list
-rw------- 1 serialband staff 10863 Sep 19 14:13 com.apple.Safari.plist
-rw------- 1 serialband staff 2216 Sep 17 19:51 com.apple.SafariBookmarksS yncAgent.p list
-rw------- 1 serialband staff 118 Sep 12 20:14 com.apple.SafariCloudHisto ryPushAgen t.plist
ls -al *firefox*
-rw------- 1 serialband staff 315 Mar 12 2018 org.mozilla.firefox.plist
ls -la *Chrome*
-rw------- 1 serialband staff 393 Aug 1 18:27 com.google.Chrome.plist
You could force a computer systemwide default by copying them to /Library/Preferences/ and force it for all users on a computer. Make sure you chmod 644 and chown root on the files you copy there, so the user can read the files but can't change it.
I used to force system wide default startup settings and extensions on all new user accounts for Windows, Linux and OS X at a previous job.
rm -rf ~/Library/Safari
rm -rf "~/Library/Application Support/Firefox/Profiles/*
rm -rf "~/Library/Application Support/Google/Chrome/Defa
Would it be simpler to force them to always start in private mode? There would be less to delete.
https://www.askvg.com/how-to-always-start-your-favorite-web-browser-in-private-browsing-mode-by-default/
https://www.howtogeek.com/137466/how-to-always-start-any-browser-in-private-browsing-mode/
I haven't done this, but it would be in the Preferences files. You could change the settings to default open in Incognito or Private mode and copy the plist file to the user.
cd ~/Library/Preferences/
ls -l com.apple.Safari*
-rw------- 1 serialband staff 42 May 9 11:59 com.apple.Safari.Extension
-rw------- 1 serialband staff 2062 Mar 30 07:51 com.apple.Safari.Support.p
-rw------- 1 serialband staff 10863 Sep 19 14:13 com.apple.Safari.plist
-rw------- 1 serialband staff 2216 Sep 17 19:51 com.apple.SafariBookmarksS
-rw------- 1 serialband staff 118 Sep 12 20:14 com.apple.SafariCloudHisto
ls -al *firefox*
-rw------- 1 serialband staff 315 Mar 12 2018 org.mozilla.firefox.plist
ls -la *Chrome*
-rw------- 1 serialband staff 393 Aug 1 18:27 com.google.Chrome.plist
You could force a computer systemwide default by copying them to /Library/Preferences/ and force it for all users on a computer. Make sure you chmod 644 and chown root on the files you copy there, so the user can read the files but can't change it.
I used to force system wide default startup settings and extensions on all new user accounts for Windows, Linux and OS X at a previous job.
ASKER
Thanks for your solution. I really want the script to work if possible and I tried above but Safari is still remembering my logged in gmail account when open after running the script.
I am also deleting everything inside user/Library/safari/* folder and it still remembers everything. Is there a folder I am missing.
I am including this folder as well rm -rf ~/Library/Safari but no luck!
Thanks
I am also deleting everything inside user/Library/safari/* folder and it still remembers everything. Is there a folder I am missing.
I am including this folder as well rm -rf ~/Library/Safari but no luck!
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is what I have but it still remembers my gmail logged into safari, I am logged in as user name "useraccount". Firefox clears up fine but safari is not working
killall -9 “firefox”
killall -9 “Safari”
rm -Rf ~/Library/Safari
rm -Rf ~/Library/Application\ Support/Firefox
rm -Rf ~/Library/Caches/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \
rm -Rf ~/Library/Caches/Metadata/ Safari; \
rm -Rf ~/Library/Caches; \
rm -Rf ~/Library/Caches/com.apple .Safari; \
rm -Rf ~/Library/Caches/com.apple .WebKit.Pl uginProces s; \
rm -Rf ~/Library/Cookies/rm -rf *Safari*;
rm -Rf ~/Library/Preferences/Appl e\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \
rm -Rf ~/Library/Preferences/com. apple.Safa ri.LSShare dFileList. plist; \
rm -Rf ~/Library/Preferences/com. apple.Safa ri.RSS.pli st; \
rm -Rf ~/Library/Preferences/com. apple.WebF oundation. plist; \
rm -Rf ~/Library/Preferences/com. apple.WebK it.PluginH ost.plist; \
rm -Rf ~/Library/Preferences/com. apple.WebK it.PluginP rocess.pli st; \
rm -Rf ~/Library/PubSub/Database; \
rm -Rf ~/Library/Saved\ Application\ State/com.apple.Safari.sav edState
rm -Rf /Users/useraccount/Library /Safari/
# remove document
#rm ~/Desktop/*
rm -rf ~/Documents/*
#rm ~/Downloads/*
rm -Rf /Users/useraccount/Library /Caches/Ap ple\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \
rm -Rf /Users/useraccount/Library /Caches/Me tadata/Saf ari; \
rm -Rf /Users/useraccount/Library /Caches; \
rm -Rf /Users/useraccount/Library /Caches/co m.apple.Sa fari; \
rm -Rf /Users/useraccount/Library /Caches/co m.apple.We bKit.Plugi nProcess; \
rm -Rf /Users/useraccount/Library /Cookies/r m -rf *Safari*;
rm -Rf /Users/useraccount/Library /Preferenc es/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \
rm -Rf /Users/useraccount/Library /Preferenc es/com.app le.Safari. LSSharedFi leList.pli st; \
rm -Rf /Users/useraccount/Library /Preferenc es/com.app le.Safari. RSS.plist; \
rm -Rf /Users/useraccount/Library /Preferenc es/com.app le.WebFoun dation.pli st; \
rm -Rf /Users/useraccount/Library /Preferenc es/com.app le.WebKit. PluginHost .plist; \
rm -Rf /Users/useraccount/Library /Preferenc es/com.app le.WebKit. PluginProc ess.plist; \
rm -Rf /Users/useraccount/Library /PubSub/Da tabase; \
rm -Rf /Users/useraccount/Library /Saved\ Application\ State/com.apple.Safari.sav edState
killall -9 “firefox”
killall -9 “Safari”
rm -Rf ~/Library/Safari
rm -Rf ~/Library/Application\ Support/Firefox
rm -Rf ~/Library/Caches/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \
rm -Rf ~/Library/Caches/Metadata/
rm -Rf ~/Library/Caches; \
rm -Rf ~/Library/Caches/com.apple
rm -Rf ~/Library/Caches/com.apple
rm -Rf ~/Library/Cookies/rm -rf *Safari*;
rm -Rf ~/Library/Preferences/Appl
rm -Rf ~/Library/Preferences/com.
rm -Rf ~/Library/Preferences/com.
rm -Rf ~/Library/Preferences/com.
rm -Rf ~/Library/Preferences/com.
rm -Rf ~/Library/Preferences/com.
rm -Rf ~/Library/PubSub/Database;
rm -Rf ~/Library/Saved\ Application\ State/com.apple.Safari.sav
rm -Rf /Users/useraccount/Library
# remove document
#rm ~/Desktop/*
rm -rf ~/Documents/*
#rm ~/Downloads/*
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
rm -Rf /Users/useraccount/Library
That's probably in the keychain. Did you have it save your account and password? That's actually separate from Safari. You'll need to open Keychain Access.App and find the entry to delete.
ASKER
No we don't use the keychain app and there is no entry in it either
ASKER
Moreover if I use Safari history cleaner then its cleans all history and no more gmail logged in too. but somehow the commands I am running not cleaning things but I don't see anything in Safari holder either I have deleted all history db files and anything within that folder and on new launch of Safari it creates all those files but brings back my logged in gmail if I goto gmail.com
Safari uses the keychain to save user accounts and passwords. They'll have their own entries in the keychain. You won't find it as *safarI*
ASKER
Thanks but again there was nothing in keychain, its a new mac , I don't even see a single entry. No worries I will just work it out as is what I have accomplished. Thanks for all your help.
ASKER
Thanks
I've done this before by...
1) Stop FireFox.
2) Delete some or all contents of related files.
3) Restart FireFox.
Last time I did this... was a very long time ago...
Check the FireFox docs or if you get stumped, just search your profile.
In my case, with latest FireFox, history data lives in places.sqlite, so you'll either delete this file or run an sqlite3 command to clear it out.
You'll just have to test + see.
Use to be FireFox recreated any missing *.sqlite files at startup, so likely just nuke the file.