I just sold my Mac. I'm currently reinstalling a fresh copy of Lion. After that, I want to install the copy of Office I'm including with it and install all the updates. After that, is it possible to turn it back so that my buyer gets the "select a language, create a user" initial setup dialogs?
You can do this by deleting the user account you created through
Note: subsitute your username in all commands that have the word username.
After you're finished installing the new software and updates restart the computer while holding
Once at the prompt enter the command:
mount -uw /
Remove user preferences:
rm -R /Library/Preferences/
Remove user account:
rm -R /Users/username/
Next start the directory services by typing:
launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
- Note you may have to use com.apple.DirectoryServicesLocal.plist (but try the above first)
Now what find groups your user belongs to:
dscl . -list /groups GroupMembership | grep username–
Remove the groups corresponding to your username:
dscl . delete /groups/username
- Do this for all of the groups you found from the above command
Remove user database:
After it's all removed type
reboot to reboot the system or
shutdown -h now to turn it off.
This hint will probably be most useful for folks who configure machines for a living, but if you're selling or giving away your machine, or just troubleshooting login issues, it may come in handy. Here are the Terminal commands to delete a temporary (or lone) account in single-user mode on Leopard (in the following commands, replace username with whatever account short name you've created). Note that this must all be done in single user mode (hold Command-S during boot).
First, the usual stuff:
$ mount -uw / $ rm -R /Library/Preferences/ $ rm -R /Users/username/
(Note that deleting /Library/Preferences/ is optional and in some cases may cause problems after pre-configuring some third-party software. However, I do this after simple configs or installs, e.g., install an OS, apply Software Updates, and then give it to the end user to create a fresh account.)
Now here's what's new in Leopard:
$ rm /var/db/dslocal/nodes/Default/users/username.plist $ rm /var/db/.AppleSetupDone
While getting rid of .AppleSetupDone wasn't really necessary for OSes 10.2 thru 10.4, you do have to get rid of the Setup flag file in Leopard, or when you reboot, you'll get a login window and no working account to log in with.
I was hoping that I might be able to just type dscl . -delete /Users/temp to axe the account info (much shorter and easier to remember), but apparently the dscl command doesn't work in single-user mode even when you follow the instructional prompt to start Local Directory Services -- oh well.
BTW, trying to do all this through the GUI is pretty much impossible. Even if you enable Root and log in as that, the Accounts prefpane in Leopard won't let you delete the last or only Admin user account.
I also discovered something interesting: if you give your temporary account (or any Admin account) no password, you'll find that when you boot up and try to run sudo from a shell (bash at least), it won't work -- it just dumps back to the main user prompt. Solve this by giving your temporary account a short password, unless you're sure that you won't have to do any superuser shenanigans from Terminal as part of the config. A good security hedge for end users who don't like passwords, but still a new wrinkle to deal with.