19

I accidentally navigated to one of those sites that pops up a dialog telling me that my computer is infected. Upon clicking the OK button, that dialog reappears, ad infinitum.

I cannot close the tab or otherwise interact with Safari while the dialog is up. No matter how many times I Quit or Force Quit (and no matter how many times I tell Safari "Do Not Re-open Windows") the previously-open set of tabs always reopens and this dialog pops to the fore.

How can I delete the state of things while Safari is closed?

3

11 Answers 11

15

From http://seanscus.blogspot.com/2012/08/completely-reset-safari.html

Open a terminal and enter the following commands to fully wipe out all of your old Safari settings:

mv ~/Library/Safari ~/Desktop/Safari-`date +%Y%m%d%H%M%S`; \ rm -Rf ~/Library/Caches/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \ rm -Rf ~/Library/Caches/Metadata/Safari; \ rm -Rf ~/Library/Caches/com.apple.Safari; \ rm -Rf ~/Library/Caches/com.apple.WebKit.PluginProcess; \ rm -Rf ~/Library/Cookies/Cookies.binarycookies; \ rm -Rf ~/Library/Preferences/Apple\ -\ Safari\ -\ Safari\ Extensions\ Gallery; \ rm -Rf ~/Library/Preferences/com.apple.Safari.LSSharedFileList.plist; \ rm -Rf ~/Library/Preferences/com.apple.Safari.RSS.plist; \ rm -Rf ~/Library/Preferences/com.apple.Safari.plist; \ rm -Rf ~/Library/Preferences/com.apple.WebFoundation.plist; \ rm -Rf ~/Library/Preferences/com.apple.WebKit.PluginHost.plist; \ rm -Rf ~/Library/Preferences/com.apple.WebKit.PluginProcess.plist; \ rm -Rf ~/Library/PubSub/Database; \ rm -Rf ~/Library/Saved\ Application\ State/com.apple.Safari.savedState

3
  • Excellent. Just what you need.
    – xbsd
    Jul 10, 2015 at 2:01
  • 1
    does not seem to work on Safari 8
    – cwd
    Aug 4, 2015 at 1:14
  • Got rid that annoying systemfailure.xyz process on Safari 9.
    – user115423
    Dec 5, 2015 at 18:38
15

Oh, my! Just press and hold Shift when launching Safari from the dock.

But you have got in answers above exactly what you have asked for)

13
  • Even now under Yosemite?
    – psoft
    Jan 3, 2015 at 3:23
  • Why don't you try?)
    – iskra
    Jan 3, 2015 at 3:25
  • 3
    This fixed it for me, no need for command-line chicanery. FWIW I was holding shift while clicking on the Launchpad icon since I don't have it in the dock.
    – dpw
    Sep 11, 2019 at 19:01
  • 2
    works for Catalina
    – uladzimir
    Jan 6, 2020 at 9:02
  • 1
    wau !!! it was freezing while opening one tab from last session ... I could not find this simple solution....
    – Renetik
    Jul 10, 2021 at 17:05
7

Disconnect your computer from the internet (disable wlan) Then delete browser history (Safari/Preferences/Privacy: remove all website data)

0
3

I created a script, DeleteSafariTabs.command, and made it executable so I can just double-click the script.

This method leaves your history and bookmarks intact, and reliably deletes the previously open tabs.

# Most apple apps (if not all) have a file inside of
# ~/Saved Application State/ so by deleting that we
# get rid of the state of open windows Safari is using.
rm -rf ~/Library/Saved\ Application\ State/com.apple.Safari.savedState

# There is also some information about the previous
# session here so we delete this as well.
rm ~/Library/Safari/LastSession.plist

You can make the file executable by typing in chmod +x, pressing the space bar, and dragging in DeleteSafariTabs.command from Finder into the Terminal window.

1
  • Might be worth trying to use formatting on those two commands to make it clearer that it is code. Jul 18, 2015 at 21:53
1

Quit Safari>Click on GO in finder> go to Folder> ~/Library/> rename folder named Safari to Safari1.

Reopen Safari, it will start new and a new Safari Folder will be created in Library.

Bring back some files like Bookmark etc one at a time.

1

For those that are really looking for an easy answer, disconnect from local network (Wifi/ ethernet). Open Safari and then force quit it to loose the cache. Then restart safari (it'll try to connect to the suspicious phishing pages but has no cached version. Go to menu -> safari -> reset safari and hit okay on popup to delete all history/ cache/ cookies etc

1

@Iskra 's answer nails it, The below steps works even there's no Safari in the dock.

1 - Open terminal

2 - Issue killall Safari

3 - Go to the list of apps (Four fingers swipe-inwards)

4 - Shift + Click Safari

0

To reset a highjacked Safari:

  • Click Go
  • select Go to folder
  • type in: ~/Library/Cookies
  • hit Go
  • Send all the frenkin cookies to the
    trash
  • Close folder
  • Launch Safari
  • You are Welcome!!!

Pass it on

0

Safari stores its window state in /Users/USERNAME/Library/Saved Application State/com.apple.Safari.savedState. If you close Safari, then rename that folder, the next time you open Safari it'll open with a blank slate.

Alternatively, you could temporarily disable the saved state feature across the board by going into the General pane of System Preferences and ticking the "Close windows when quitting an appellation" checkbox. If you open Safari after doing that, it'll also open with a blank slate. Remember to untick it afterward if you want to turn the saved state feature back on.

3
  • This is no longer true in Yosemite, there's no such folder for me. Apple changes this sort of thing on a per-build basis so I wouldn't count on it.
    – 2rs2ts
    Jan 21, 2015 at 23:03
  • They don't change it. That folder has been the same for quite a few OS releases. However I did screw up the path in my answer originally; that's why you wouldn't have found it. I've fixed the path in my answer now. If you check for the amended path you should find it now. Jan 21, 2015 at 23:14
  • Aye, I can find it now. But my warning still stands, as Apple does in fact change the location of settings all the time.
    – 2rs2ts
    Jan 22, 2015 at 15:44
0

I just typed google website on a word sheet, clicked on the link then go to preferences and change the home page back.

0

I find it most useful to create a .bash_alias file and add it to your .bash_profile.

Add this alias to .bash_alias and any other useful command line scripts.

alias resetsafari='rm -rf ~/Library/Saved\ Application\ State/com.apple.Safari.savedState; rm ~/Library/Safari/LastSession.plist

You will need to source .bash_profile again to refresh the aliases.

In the event you forget your saved aliases, just type alias into Terminal to see all current aliases.
(This is a modification of the code someone posted above, modified into an alias form.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .