Reset Safari from command line
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?
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
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)
Disconnect your computer from the internet (disable wlan) Then delete browser history (Safari/Preferences/Privacy: remove all website data)