9

I'm selling my 2007 White MacBook.

In line with many suggestions I've seen online I've securely wiped the drive and done a re-install but have hit a problem.

The machine came with OS X 10.4 Tiger but I've since upgraded it to Leopard then Snow Leopard.

Ideally I'd like to give the new owner the new MacBook experience with the spinning Welcome text but I'd also like to stick them on the latest Snow Leopard. The problem is, when I do a fresh install of Snow Leopard the machine won't have the iLife applications (they are on the original Tiger install disks).

Is there a way I can get the iLife apps on there without needing to set up an account on the machine?

If not, what's the best thing to do? Setting up an account is something I'd rather not do (I know I'd be annoyed if I bought a second-hand MacBook and it already had an account on it). On the other hand installing Tiger and giving them the upgrade disks also seems a bit poor.

Any suggestions please?

Thanks in advance.

Follow up:
All the answers below were very informative, clearly explained and probably equally effective. I chose the one that best suited my circumstances but hopefully they will all be of use to future readers of this question. Thanks to all who contributed.

3 Answers 3

8

Two things - if you don't know the basics of a unix shell syntax (having a space in the right place matters, punctuation like / matters) don't do step 2 unless you can afford to re-install everything again - the rm command is unforgiving - delete the wrong file or directory with rm -rf and the mac won't boot. You can be more secure by using the srm command instead of rm and it will slowly shred the files - I use srm -sz -rf instead of rm -rf below to shred once and then zero out (which ends up being two passes and then a delete - plenty secure for my needs and not as slow as the default 35 pass overwrite before the delete)

  1. Do make sure the person buying the machine knows what they are getting recovery disks for. It's really nice to make a test account to run all the updates rather than hand them the Snow Leopard disk.

  2. Set up your Snow Leopard Mac to add one admin account named test with no password and delete any other accounts using the test account. Reboot into single user mode by holding command + s and type these exactly:

    /sbin/mount -uw /
    cd /var/db
    srm .AppleSetupDone
    cd dslocal/nodes/Default/users
    srm test.plist
    cd /Users
    rm -rf test
    halt

You can now boot the mac to see the setup welcome movie plays and quit the assistant a few steps in using command + q when it starts asking name questions and it will shut down with no account created but all the applications preserved. It will remember your wifi settings, so delete those before starting step 2 or use ethernet/a safe public wifi to run updates if you're worried about that sort of thing.

2
  • After weighing up all the options I've gone for this approach. Thanks for the tip about running all the updates and laying out the commands in a clear manner. Commented May 3, 2011 at 20:54
  • Great feedback here and with Hobs' more robust (and more complicated) script. I've relied on this many tens of times to freshen up a machine for a new user.
    – bmike
    Commented May 3, 2011 at 21:20
8

You could definitely install iLife, boot into single user mode, delete the user account via this superuser link(also below, and do it in single user mode), and then in single user mode just type rm /var/db/.AppleSetupDone which is like a toggle switch, it tells the mac to start from the initial boot.

#!/bin/bash

# cf. http://www.macos.utah.edu/documentation/authentication/dscl.html

if [[ "$(/usr/bin/whoami)" != "root" ]]; then printf '\nMust be run as root!\n\n'; exit 1; fi

OPATH=$PATH
export PATH=/usr/bin:/usr/sbin:/bin:/sbin

OIFS=$IFS
export IFS=$' \t\n'

declare sudo=/usr/bin/sudo

printf "\e[1mDelete user account\e[m: "
read user

if [[ -z "$user" ]]; then printf '\nNo user specified! Please, try again!\n\n'; exit 1; fi

# make sure the user exists
usertest="$(/usr/bin/dscl . -search /Users name "$user" 2>/dev/null)"

if [[ -z "$usertest" ]]; then printf "\nUser does not exist: $user\n\n"; exit 1; fi 


# get user's group memberships
groups_of_user="$(/usr/bin/id -Gn $user)"

if [[ $? -eq 0 ]] && [[ -n "$(/usr/bin/dscl . -search /Groups GroupMembership "$user")" ]]; then 
   # delete the user's group memberships
   for group in $groups_of_user; do
      $sudo /usr/bin/dscl . -delete "/Groups/$group"  GroupMembership "$user"
      #$sudo /usr/sbin/dseditgroup -o edit -d "$user" -t user "$group"           
   done
fi


# delete the user's primary group
if [[ -n "$(/usr/bin/dscl . -search /Groups name "$user")" ]]; then
   $sudo /usr/sbin/dseditgroup -o delete "$user"
fi

# if the user's primary group has not been deleted ...
if [[ -n "$(/usr/bin/dscl . -search /Groups name "$user")" ]]; then
printf "
   \e[1mWarning\e[m:
   The group memberships of the user \e[1m$user\e[m have been deleted\x21
   groups_of_user: $groups_of_user
   The user's primary group \e[1m$user\e[m, however, has not been deleted\x21
   Please, try again\x21
   Exiting ...\n
"
  exit 1
fi


# find the GeneratedUID of the user and remove the password hash file 
# from /private/var/db/shadow/hash/<GeneratedUID>
# sudo ls -a /private/var/db/shadow/hash
# sudo ls -l /private/var/db/shadow/hash/<GeneratedUID>

guid="$(/usr/bin/dscl . -read "/Users/$user" GeneratedUID | /usr/bin/awk '{print $NF;}')"

if [[ -f "/private/var/db/shadow/hash/$guid" ]]; then
   $sudo /bin/rm -f /private/var/db/shadow/hash/$guid
fi


# delete the user
$sudo /usr/bin/dscl . -delete "/Users/$user"

# make a backup
if [[ -d "/Users/$user" ]]; then
   $sudo /usr/bin/ditto -rsrc -c -k "/Users/$user" "/Users/${user}-archive-$(/bin/date).zip"
fi

# remove the user's home directory
if [[ -d "/Users/$user" ]]; then
   $sudo /bin/rm -rf "/Users/$user"
fi

export IFS=$OIFS
export PATH=$OPATH

exit 0
4
  • Thanks for the information - am going to try the other suggested option but will try this if that one fails. Commented Apr 27, 2011 at 22:07
  • Good luck! Let us know how it goes. Commented Apr 28, 2011 at 3:56
  • When booted into single user mode in Snow Leopard, this script does not work for me -- it says the user does not exist.
    – Ivan X
    Commented Sep 16, 2015 at 10:33
  • Then for some reason root doesnt exist when running /usr/bin/dscl . -search /Users name "$user" (where $user is root). Thats pretty weird. Commented Sep 16, 2015 at 16:41
2

Install Tiger like normal, then boot off the Snow Leopard install discs and do an upgrade-install without booting off the internal drive and making a user account.

2
  • This sounds a bit simpler than the clean-up option suggested so will give it a try - thanks. Commented Apr 27, 2011 at 22:06
  • It's also quite easy to delete a test user. I'll give an answer to cover that that's far simpler than the script above that is a little more thorough, but that extra checking and leaving a backup copy of an "empty" home folder is not warranted in the situation you describe.
    – bmike
    Commented Apr 27, 2011 at 22:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .