How to reset Lion back to the Setup Assistant

Dec 05, '12 07:30:00AM

Contributed by: jolinwarren

There have been previous hints on how to reset earlier versions of Mac OS X to delete users so that it boots to the Setup Assistant again. This can be useful if you are passing on or selling your computer to someone else. The most recent hint was posted in 2007 for Mac OS X 10.5 and there were significant corrections included in the comments. There is also a command that changed in 10.7 (also in the older hint’s comments) and even with the modifications suggested in the comments, the hint is still incomplete.

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.

2: Still in System Preferences, click Show All at the top left and then click the Users & Groups icon. Delete all users except for the one you are currently logged in as. In the rest of this hint, this remaining user will be referred to as USERNAME.

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…]

Comments (18)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20121202080339900