How to reset a Mac OS X installation
Heres how to reset an installed Mac OS X and virtually return to a virgin state with a welcome screen prompting the user to setup and customize his Mac OS X installation:
1. Press Command-S during startup to get into single user mode
2. Check the filesystem:
# /sbin/fsck -fy
3. Mount the root partition as writable:
# /sbin/mount -uw /
4. Remove the hidden .AppleSetupDone file:
# rm /var/db/.AppleSetupDone
5. a) For Mac OS X 10.5 Leopard and newer, do:
# launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist &
Repeat for every user previously defined on the machine (replace {username} with the real user name):
# dscl . -delete /Users/{username}
(optionally execute the next line, most people won't probably need it)
# dscl . -delete /Groups/admin GroupMembership {username}
5. b) For older versions of Mac OS X, do:
# rm -rf /var/db/netinfo/local.nidb
6. Remove the home directories of users. For every user do (replace {username} with the real user name):
# rm -rf /Users/{username}
7. If applicable, remove already created files in roots home directory, e.g.
# rm /root/.bash_history
8. Reboot:
# reboot
You can also optionally remove the files in /Library/Preferences with:
# rm -R /Library/Preferences/
This could effect some third party apps installed.
Oh and it's useful to point out this method will not touch the installed OS, or installed Apps, just remove personal data, and reset the OS to a "welcome state."
Hope you find it useful, I've used it for ever Mac I've sold in the last 5 years.
-Cheule