I'm searching a tool that deletes all personal files of an user account automatically. We have a small network of new Imacs for students and they save all kind of stuff on the harddrive.

So we want to delete all that crap on a reboot.

We could maybe even delete the student account and create a new one automatically.

Is there a tool or script to do that for OSX 10.9.4?

  • Are you looking to erase all user data, or sort data and then erase certain files/folders? – thankyour Aug 13 '14 at 14:55

Deep Freeze sounds like what you might need, restore the machine to any given state at reboot - http://www.faronics.com/products/deep-freeze/

  • Deep freeze is good, however there is overhead in terms of having to unfreeze machines to update them and in terms of configuration. You also have to be aware that it has issues with fusion drives – Paul Gilfedder Aug 13 '14 at 9:02
  • @PaulGilfedder You can always turn off fusion drive, I doubt students need that speed boost anyway. As for unfreezing to update, that's a good feature, not sure why you're nitpicking that. It isn't like you'll be updating it all the time, and it's easy enough to do. – Brian Graham Aug 13 '14 at 10:06
  • Just flagged it as we found it out the hard way and caused a certain amount of pain as it only showed up late in our process. I am not dissing Deep Freeze, we like it and has certainly lowered maintenance costs on our machines – Paul Gilfedder Aug 13 '14 at 10:09

You could make a LaunchDaemon that runs each time the system is booted.

Example script (from another question):


for user in $( ls /Users ); do
 if [[ "$user" != "<someadmin>" || "$user" != "<someotheradmin>" ]]; then 
  rm -rf "/Users/$user"

If you merely use the example script above and call it from a LaunchDaemon, it will erase the users' data (except for "someadmin" and "someotheradmin") each time OS X starts up, but their account will still be on the system. This means that the students could still log in, but their home folder would be recreated each time they logged in.

To remove users from OS X's directory (either local accounts or mobile accounts from a networked directory), use dscl: dscl . -delete "/Users/$user". Add that line right after the rm -rf. Depending on your directory, more investigation might be necessary. :)

  • This deletes the whole user directory. If I read the question correctly, the OP wants to keep the accounts and just needs to delete documents created by the users (leaving Library intact for instance). The script might require some tweaking for this. – nohillside Aug 13 '14 at 13:05
  • @patrix Good point. I think the question should be edited to reflect. – thankyour Aug 13 '14 at 14:55

You must log in to answer this question.

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