Create admin user on Mac OS X as root
If you've experienced bringing your Mac in for a repair and you weren't given any new password for your admin account when you receive your Mac... you're going to be in for a surprise when you get home.
How to deal with this:
-
Don't panic. Don't be depressed. Don't go back to the Apple repair shop. You can do it yourself very easily even if you don't have an install USB / CD.
-
Change your name to another name. Go to System Preferences > Users & Group. Maybe try adding '1' at the end of your name. This is so that it will not conflict with the new account you will be setting up.
-
Reboot your machine in single-user mode. As soon as you hear the boot chime (single note or chord), press
Command + S
. This allows you to boot into single user. Other option is booting into verbose mode, which is detailed here: http://support.apple.com/kb/ht1492. You will see a lot of display from the terminal. If you're unfamiliar with what you see, just wait for this lineroot#
-
Test the disk first. When you see the prompt:
root#
, key in:fsck -y
(and hit enter). Fsck is a filesystem consistency check and interactive repair, and they
option is to default a yes answer to all of fsck's options. You will see some checks and finally say that your disk is OK. -
Mount it for read-write. This makes the drive ready for write operation or modification. Key in this command:
mount -uw /
(and hit enter). Theu
option marks that the volume's status should be changed, and thew
option tells the mount command to make the volume available in read-write mode. -
Remove the AppleSetupDone setting. This file flags that the system has already been set up. This means you have already gone through the Language, Keyboard, Timezone, Default User setup. However, since for our scenario, we wanted to redo the setup to customize to our requirements, we will need to remove this. Key in
rm /var/db/.applesetupdone
(and hit enter). -
Reboot into normal mode. Key in
reboot
(and hit enter). Let it reboot normally until you hit a screen that will walk you through creating your account. This time around, create your default user with your elected password. -
Remove previously created account. Go to System Preferences > Users & Groups again and remove the previous account securely.
-
???
-
PROFIT!!!
Now you're armed and ready! Enjoy your fresh clean Mac! :)