How to Reset Mac OS X Lion to Factory Default State
Getting ready to sell your Mac and want to do a full factory restore to default settings? Just follow this procedure — it works on Mac OS X Lion only.
1. Launch the Terminal application on you Mac. Then run the following sequence of commands (one at a time):
sudo su
dscl . -delete /Groups/admin GroupMembership yourAccountNameHere
dscl . -delete /Users/yourAccountNameHere
2. Now reboot your Mac into single-user mode by holding Command-S at startup.
3. Once booted into single-user mode, run the following sequence of commands (one at a time):
/sbin/fsck -fy
/sbin/mount -uw /
rm -R /Users/yourAccountNameHere
cd /var/db/
mv .AppleSetupDone .RunLanguageChooserToo
rm -R /Library/Caches/*
rm -R /System/Library/Caches/*
rm -R /var/vm/swapfile*
reboot
Your Mac will reboot 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.
Advertisement

Brilliant. Worked like a charm.
Frosty
29-January-2012 at 22:20
hey, what will happen to the user data that is present in the harddisk
abhi
1-February-2012 at 09:10