Reset dock icons while log off I have an iMac for public use, I want to ensure the dock icon won't be changed by others (i.e. keep factory setting).

Currently I know the following two commands can do this:

defaults delete com.apple.dock
killall Dock


However, when I insert this two lines of code into an Logoff script, it won't work.

#!/bin/bash

#Reset the dock
defaults delete com.apple.dock
killall Dock

exit 0


The script is OK and other commands in that script are functioning too.

Any idea to solve this problem?
Since you're logging out you can just delete the com.apple.dock.plist file in the script using the rm command and no need to use the killall and defaults commands.  I just tested this with a logout script and it reset the Dock to the default Dock when logging back in.

I used: rm "/Users/$USER/Library/Preferences/com.apple.dock.plist"