We have hundreds of computers with LDAP setup and when students login their profiles remain for life. IS there an easy script or something that could be run to clean out the entire /Users directory all but select users?


Provided you're merely dumping the user data, you could use a bash script. Something like:


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

For removing users from the local directory, you need to use dscl. Check out this SuperUser answer for a launching pad on using dscl to remove an account from OS X's local directory.


If this is a lab you may just want to reset them back to a disk image periodically. This way any changes including any saved files will be lost, but it would return the machine back to a predetermined state.

  • Normally I would agree with that statement, but from ARD the task can be done in a few minutes. Trying to image and setup almost 100 laptops to ethernet ports takes too much hands on time. – Jason Jun 4 '14 at 19:15
  • Is it OK to have these user's deleted daily? Is it possible to have the students use guest accounts? Could you dictate that the students connect the laptops to Ethernet port at a designated time? – echeola Jun 4 '14 at 20:42

You must log in to answer this question.

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