1) Do all of the necessary installations, etc. just as under Snow Leopard, using your setupacctname account.
2) Once that is done, BEFORE restarting in single user mode:
sudo su3) Reboot into single user mode (Hold Command-s at startup)
dscl . -delete /Groups/admin GroupMembership setupacctname
dscl . -delete /Users/setupacctname
4) Check the filesystem:
/sbin/fsck -fy5) Mount the filesystem:
/sbin/mount -uw /6) Remove the setupacctname directory:
rm -R /Users/setupacctname7) Remove or rename .AppleSetupDone so you get the language choice
cd /var/db/or
mv .AppleSetupDone .RunLanguageChooserToo
rm .AppleSetupDone8) Delete miscellaneous files (unnecessary, but useful if you're imaging the drive):
rm -R /Library/Caches/*9) Shutdown or restart
rm -R /System/Library/Caches/*
rm -R /var/vm/swapfile*
On next boot your Mac will go to the start of the initial Apple Setup program just like when you first powered it on after purchase. All clean and ready to sell or give to a new user.
Another way of doing it is:
restart in single user mode by holding Command-S at startup and then run:
/sbin/fsck -fy
mount -uw /
rm var/db/dslocal/nodes/default/users/<shortname>.plist
rm -r users/<shortname>
rm var/db/.AppleSetupDone
reboot