Category filter
Script to clear browser history on Mac
Every webpage the user visits is logged and stored by the corresponding web browser on the device. The browsing history includes download history, search history, cookies, cache, etc., which ultimately accumulates over time. Admins can remove the browser history of users to avoid leakage of this information or free up storage space. This document provides the custom script to remotely delete the browsing history logged by Google Chrome and Firefox apps on macOS devices using the Execute Custom Script action.
Scripting Language – Bash
File extension – .sh
Delete Google Chrome browsing history
Google Chrome app stores the browsing history of a user on a file named History in the location “Library/Application Support/Google/Chrome/Default” on macOS devices. Delete this file using the rm
command to erase the browsing history on Google Chrome.
1 2 |
LOGGED_USER=`stat -f%Su /dev/console` sudo su $LOGGED_USER -c 'rm -R /Users/<user name>/Library/Application\ Support/Google/Chrome/Default/History' |
Replace <user name>
with the target username on the device.
For example:
LOGGED_USER=
stat -f%Su /dev/console
sudo su $LOGGED_USER -c 'rm -R /Users/testacc/Library/Application\ Support/Google/Chrome/Default/History'
Delete Firefox browsing history
The Firefox app stores the browsing history of a user on a file in the location “Library/Application Support/Firefox/Profiles” on macOS devices. The file name will differ depending on the storage device. Use the rm
command to delete all files under the Profiles folder. It’s worth noting that deleting all files will also remove bookmarks and caches stored by Firefox.
1 2 |
LOGGED_USER=`stat -f%Su /dev/console` sudo su $LOGGED_USER -c 'rm -R /Users/<user name>/Library/Application\ Support/ Firefox/Profiles' |
Replace <user name>
with the target username on the device.
For example:
LOGGED_USER=
stat -f%Su /dev/console
sudo su $LOGGED_USER -c 'rm -R /Users/testacc/Library/Application\ Support/Firefox/Profiles'