So instead of adding yet another modification in the comments of a hint related to 10.5, I thought I would submit a new hint brining everything together from the old hint, its comments, changes needed for 10.7, and the missing items I have found. This provides a current version of the hint for 10.7 and presumably 10.8, though I have not been able to test on Mountain Lion.
1: Remove references to, and the stored passwords for, your local WiFi network.
- In the Finder, choose Go > Utilities.
- Open Keychain Access in the Utilities folder.
- If you don’t have a list of keychains on the left, choose View > Show Keychains.
- On the keychains list on the left, select the System keychain. There should be an AirPort network password item in the list for your local WiFi network. Select it and press Delete. Confirm that you want to delete the item and quit Keychain Access.
- Go to System Preferences > Network
- Select Wi-Fi from the list on the left and click the Advanced button on the bottom right.
- In the‘Preferred Networks: list, select your network and click the minus button below the list.
- Click OK and then Apply button in the main Network Preferences window.
- Click Turn Wi-Fi Off, then click it again to turn Wi-Fi back on. It should not connect to your network anymore (and should ask for a password if you try).
3: Boot your Mac into single user mode by restarting and holding down Command-S at startup.
4: Mount the filesystem in write mode and delete the USERNAME home directory.
$ mount -uw /
$ rm -R /Users/USERNAME/
5: Load OpenDirectory so we can remove the system’s record of USERNAME.
$ launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
6: Find the UID of USERNAME.
$ dscl . -read /Users/USERNAME GeneratedUID
In the next step, type in this UID where you see GENERATEDUID written.
7: Remove USERNAME from the systemwide admin group and then remove USERNAME’s record.
$ dscl . -delete /Groups/admin GroupMembers GENERATEDUID
$ dscl . -delete /Groups/admin GroupMembership USERNAME
$ dscl . -delete /Users/USERNAME
8: Remove the Setup Assistant flag so that it runs when the Mac is started up.
$ rm /var/db/.AppleSetupDone
9:[optional] Remove the cache files and virtual memory swapfile.
$ rm -R /Library/Caches/*
$ rm -R /var/vm/swapfile*
10:
$ shutdown -h now
If you want to check that the Setup Assistant will run, you can turn on your Mac. When the Setup Assistant starts, just press cmd-Q on the keyboard and you will be prompted to shut down. Your Mac has been reset.
[kirkmc adds: I'm running this hint because it contains a lot of useful information. But I wonder why one can't simply erase the hard disk and re-run the installer to get everything back to its initial state. That seems a lot easier to me…]