Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: How to reset Leopard back to the Setup Assistant Install
This really old hint has the basics for resetting a machine back to no users, so it boots to the Setup Assistant again. Things have changed in Leopard, so here's some new info.

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.
    •    
  • Currently 3.33 / 5
  You rated: 2 / 5 (15 votes cast)
 
[175,483 views]  

10.5: How to reset Leopard back to the Setup Assistant | 23 comments | Create New Account
Click here to return to the '10.5: How to reset Leopard back to the Setup Assistant' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: How to reset Leopard back to the Setup Assistant
Authored by: tomq on Nov 21, '07 09:46:20AM

I could really use this hint, but it didn't work for me. Here is the substance of the original hint:
-------------------------------------------
According to Apple, to re-run the assistant, you need to:

1. Boot into single-user mode (command-S during startup)
2. Once the command-line prompt appears, type the following:

mount -uw /
cd /private/var/db/netinfo
mv local.nidb local.old
rm ../.AppleSetupDone
exit

When you hit RETURN after typing exit, OS X will restart and the setup assistant will launch automatically. So if you've somehow messed up your primary OS X user, this is a good fix that may get you up and running again, even if re-running the OS X installer does not.
-----------------------------------------------

There is no "username" to replace (that I see) as suggested in the new hint.

When I use the "mv" or "rm" lines I get "no such file or directory". Anybody have any ideas? I am new to the command prompt so exact details would be much appreciated. Any "assumed" details in the recipe would be missed by me.



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: tomq on Nov 21, '07 09:48:52AM

Ooops. I missed the bulk of the new hint. Sorry, I'll try that.



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: tomq on Nov 21, '07 10:36:29AM

Okay. I have now tried the NEW hint and all goes well until I try:
rm /var/db/ .AppleSetupDone

at which time I'm told that no such file or directory exists. So when I reboot I just get a blank Name and Password Leopard login screen. Now, of course I have no users. What might I be doing wrong? TIA



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: jolinwarren on Nov 21, '07 10:56:53AM
There should be NO space between the 'db/' and '.AppleSetupDone'. So the last command you type in should be:
rm /var/db/.AppleSetupDone
The only space in that command is the one between 'rm' and '/var/...'. Hope that helps.

[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: baf on Nov 22, '07 09:43:46PM

I don't know if you wrote it wrong here or copy paste but there should not be a space after /var/db
It should be one "word" after rm

rm /var/db/.AppleSetupDone



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: BigMax on Nov 21, '07 11:03:07AM
You can use dscl from Single User mode, but first you must enable the directoryServices plist using launchd. Here is the command:
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist &


[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: mike666 on Nov 23, '07 02:38:03PM

Interesting - starting DirectoryServices didn't work when I originally tried it on an Intel mini with a fresh 10.5 install. I just tried it on one of our demo machines and it did work, though. I guess it's up to you whether you want to delete the plist file or zap the account through dscl - both accomplish the same thing and require almost the same amount of typing...



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: MonsieurBon on Nov 29, '07 12:32:33PM

Actually, if you just delete the plist file, the first user you create on the new system has a UID of 502. If you load DS instead, and then use dscl to delete the account, the first user you create on the new system has a UID of 501.

So this indicates to me that deleting the plist file may in some way be an incomplete method of deleting the user.



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: tomq on Nov 23, '07 07:26:43AM

That was it. Thanks.



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: MonsieurBon on Nov 29, '07 05:32:32PM
I would strongly recommend AGAINST just deleting the plist file and the user folder.

I tried that method and compared it to using dscl properly. If you just delete the plist file and the user folder, it leaves things behind that can cause problems. For example, when I just deleted the plist and the user folder, rebooted the system, went through setup, created a new user, and launched keychain, the keychain password for the NEW user's keychain was that of the original user I had deleted.

So I would suggest you use the following method for deleting a user in single-user mode when prepping a system image or setting it up for a new user, instead of just deleting the plist file:

/bin/launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist &

dscl . -delete /Users/temp


[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: arikahn on Dec 02, '07 03:57:02PM

the command line is clearly so powerful, but it makes me feel like a monkey copying somebody else's work. Oh well.

When I type in
/bin/launchtl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist &

I get /bin/launchtl: No such file or directory.

Am I missing something?

This is a great hint-- I'm trying to clean up my old machine for resale-- and this would come in handy.






[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: arikahn on Dec 02, '07 07:35:00PM

D'oh nevermind. I see that I missed the second 'c' in launchctl.



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: paulmob on Dec 07, '07 03:44:33AM
Steps that worked for me:

1) Boot mac into single user mode by holding down Command-s at startup.

2)

$ mount -uw /
$ rm -R /Library/Preferences/
$ rm -R /Users/USERNAME/
3)
$ /bin/launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist &
$ dscl . -delete /Users/USERNAME
4)
$ rm /var/db/.AppleSetupDone
5)
$ exit
6) That's it!
Other notes about Setup Assistant that have been covered elsewhere but are useful to know:

You can quit the Setup Assistant by pressing Command-q before sending your information to Apple.

You can also shutdown from the Setup Assistant by pressing Command-q.

You can access the original video and audio (separate files) from the intro to Mac OS video by entering the following text into a terminal window:

$ cd /System/Library/CoreServices/Setup\ Assistant.app/Contents/Resources/TransitionSection.bundle/Contents/Resources/
$ open intro.mov
$ open intro-sound.mp3


[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: Hellokitty on Aug 07, '09 04:00:03PM

So I forgot my password and I have important files on my old account. If I try this, will my old admin account be delete? What about the other normal accounts, will they have everything on their that they had before? Thank you!



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: gilburns on Feb 18, '08 10:51:30AM

You should also clean up the admin group when deleting the user account.

$ dscl . -delete /Groups/admin GroupMembership USERNAME

That will remove the old username that you are deleting from the admin group.





[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: frogmella on Jul 08, '08 01:17:47AM

One thing to add: if you're doing this to put your Mac on eBay (or Freecycle if it's really that old!), you probably want to do this without re-running the assistant so that the new owner can run it for herself. In which case, instead of the final
exit
use the following instead:
shutdown -h now



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: skydiverx on Sep 26, '08 12:10:22PM

Also, if you want to be thorough, I would erase the system log files.

Here's the steps taken from all the suggestions plus erasing the log files.

--------------------------------------------

1:
Boot mac into single user mode by holding down Command-S at startup.

2:
$ mount -uw /
$ rm -R /Library/Preferences/
$ rm -R /Users/USERNAME/
$ rm -R /Library/Logs
$ rm -R /var/log

3:
$ /bin/launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist &
$ dscl . -delete /Users/USERNAME
$ dscl . -delete /Groups/admin GroupMembership USERNAME

4:
$ rm /var/db/.AppleSetupDone

5:
$ shutdown -h now

That's it!



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: emilholt on Nov 26, '09 01:35:13AM

This is a really bad idea.
It recursively deletes the /Library/Preferences, /Library/Logs and /var/log directories leaving you with a broken system.
If you want to delete the logfiles you should delete the specific files.



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: daytonabeach on Oct 22, '08 01:02:06PM

Hi!

Whats does the $ means?
Is it just some fancy sign for a special command? I doesnt appear to be included in the commands?

Then, how do i know if there are any separation between the different command?
Do i hit enter for each line, if so, i get back to a new line with "rooth" and no message about anything being executed, is that correct?



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: glusk on Nov 03, '08 11:19:42AM

In most unix systems, your command prompt ends in a $. If you have superuser privileges, your prompt probably ends in a #.

They're usually included in these posts to indicate a new command line. Might make it a little confusing when copy/pasting though.




[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: nevernot on Aug 05, '11 12:22:52PM

I was wondering if anyone has used this successfully in Lion. I've been using this for a few years now with great success but it looks like they changed the location or name of com.apple.DirectoryServices.plist from the command /bin/launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist & . Anyone know how to proceed from here?



[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: brewsta on Dec 20, '11 01:03:32PM
$ mount -uw /
$ rm -R /Users/USERNAME/
$ /bin/launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
$ dscl . -delete /Groups/admin GroupMembership USERNAME
$ dscl . -delete /Users/USERNAME
$ rm /var/db/.AppleSetupDone
OPTIONAL STEPS HERE:
$ rm -R /Library/Caches/*
$ rm -R /System/Library/Caches/*
$ rm -R /var/vm/swapfile*
$ shutdown -h now
THESE WILL PROBABLY TRASH YOUR SYSTEM, SO IF YOU SEE THEM RECOMMENDED, DON'T DO THEM:
$ rm -R /Library/Preferences/
$ rm -R /Users/USERNAME/
$ rm -R /Library/Logs
$ rm -R /var/log
Apple's Knowledge Base entry for using DSCL in Single User Mode under Lion:
http://support.apple.com/kb/HT4749

Note: When running dscl(1) from Single User mode, you'll see this message:

launchctl: Couldn't stat("/System/Library/LaunchDaemons/com.apple.DirectoryServicesLocal.plist"): No such file or directory nothing found to load
This message can be safely ignored.


[ Reply to This | # ]
10.5: How to reset Leopard back to the Setup Assistant
Authored by: nevernot on Dec 22, '11 06:11:39AM

Thanks for the reply! I noticed the dscl error and kinda freaked out a bit. I've been doing basically the same process through the gui with decent results but it's way more time consuming. You are correct about deleting /Library/Preferences though, it seems the keyboard maps are in there now because if you delete it the setup assistant doesn't progress past that section. Thanks again



[ Reply to This | # ]