Serge Stikine's stuff

Just another WordPress site

How To: Reset Mac OS X Lion/Mountain Lion to factory default

 

How to reset Mac OS X Lion/Mountain Lion to Factory Default

Always make a fresh backup before you will get under the hood of your MAC!

BE VERY CAREFUL WHEN USING THE “rm” command as you may delete your whole drive!
DO THIS AT YOUR OWN RISK. I TAKE NO RESPONSIBILITY FOR ACCIDENTAL LOST OF DATA.
BACKUP IF DOING THIS WHERE THERE IS DATA ON THE DRIVE NEEDED TO BE SAVED

REQUIRED USER LEVEL:  USER WITH ADVANCED KNOWLEDGE OF THE MAC OS X AND SELL !

Recently I have a client which asked me to reset his MBP to factory default. This client purchased latest Retina MBP and want to sell old one.

first of all you need to clean your Do

One of the important thing which you need to do -deauthorizing a computer. Open your iTunes and go to Store and click on the “Deauthorize This computer…” then if you have Audible account go to Advanced and  Deauthorize Audible Account…”

You will need to start your mac in Single User mode to clean disk and system . Reboot your system and immediately after Mac startup sound press and hold following combination: ⌘+S

Users of Mac-mini with non Apple keyboard: I cannot guaranty you will be able to get in to single user mode.

1.

For beginning to prevent any OS damage please execute following command

/sbin/fsck -fy
Because you started system in single user mode Macintosh HD mounted in read only mode. To work with system settings it is necessary to change mount settings to Read/Write. Please execute following:
/sbin/mount -uw /

Now it is time to load OpenDirectory service:

For MAC OS X up to 10.6

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

If you have Mac OS X 10.7 and newer:

launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist

2.

To check in which groups you are listed, enter:

dscl . -list /groups GroupMembership | grep yourusername

Most likely you will receive following respond from the system.

root#dscl . -list /groups GroupMembership | grep yourusername
_appserveradm                 yourusername
_appserverusr                 yourusername

_lpadmin                                    yourusername
admin                                                               root yourusername
com.apple.sharepoint.group.1        yourusername
stuff                                                                  yourusername
removing your name from the groups:
dscl . delete /groups/groupname GroupMembership yourusername
where is:
        groupname – name of the group. For example “stuff”
        yourusername – yours short user name (you can find it in /Users/ directory (name of your home directory)
Repeat dscl command for all groups where is your short user name listed
Deleting group with your name (if it is created by system)
dscl . delete /groups/yourusername
Following string will delete your user name from open directory:
dscl . delete /users/yourusername
Remove your user ID file from Open Directory:
rm /private/var/db/dslocal/nodes/Default/users/yourusername.plist
Delete all users directory
rm -rf /Users/yourusername
Clean system locations from logs, Caches and TMP files/folders

rm -rf /Library/Preferences/*
rm
-rf /Library/Logs/*
rm
-rf /private/var/log/*

rm -rf /Library/Caches/*
rm -rf /System/Library/Caches/*
rm /private/var/vm/swapfile*

rm -rf /private/var/folders/*

Removing from the system file which created after system setup:
rm /private/var/db/.AppleSetupDone
Clean root home directory.
rm -rf /private/var/root/*
Check everything then recheck it again. When your are sure everything clean, you can shutdown your system.
shutdown -h now
About these ads

Written by Stikine

July 13, 2012 at 12:00

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: