Change the Admin Password with Mac OS X Single User Mode

Apr 25, 2011 - 48 Comments

Change Unknown Admin Password in Mac OS X

If you’re in IT, or just fixing Grandmas Mac, it’s not too uncommon to get a machine where you don’t have the admin users password. If you find yourself in this situation, you can easily change the Admin password, or any other users, simply by booting into Mac OS X‘s command line Single User Mode. I consider this to be essential knowledge for troubleshooting Macs.

Change an Admin Password in Mac OS X Single User Mode

This is a multistep process but it’s easy to follow:

  • First you need to enter Single User Mode. Reboot the Mac and hold down Command+S at boot to enter into the command line.
  • You’ll see a note where Mac OS X tells you that you need to run two commands in order to make filesystem changes, this is necessary so let’s handle that first
  • The first command checks the Mac OS X filesystem for errors and fixes them, it can take a few minutes to run:
  • fsck -fy

  • The next command mounts the root Mac OS X drive as writable, allowing you to make changes to the filesystem:
  • mount -uw /

  • After the filesystem is mounted, you can reset any users password using the following command:
  • passwd username

  • You’ll need to enter the new password twice to reset and confirm the changes

Note that a password will not be visibly typed when using the ‘passwd’ command, it looks as if nothing is being entered at all. That is standard practice in the command line world.

Changing Admin Password in OS X Lion, Mountain Lion, and later

For users with OS X 10.7.3 and later, including OS X 10.8+ Mountain Lion, there may need to be an additional step to load open directory. If you have issues with the above approach, try the following command sequence with newer versions of Mac OS X. Note the primary difference is using ‘launchctl’ between mounting the drive and changing the password:

#1 fsck -fy
#2 mount -uw /
#3 launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
#4 passwd username

The password should now change as expected, where you can then reboot and use the admin user account as expected. Rebooting is possible through the command line by by typing:

reboot

Or by using the standard manual restart methods of keyboard shortcuts, shutdown, or holding down the power button. On the next boot the changed admin password will be usable as anticipated.

Don’t know the admin username? No problem
If you’re fixing someones machine and you don’t know the username to reset, just look in /Users with:

ls /Users/

Here you’ll see at least three items, .localized, Shared, and a username. The username is what you’ll want to change with the passwd command.

After the password is reset and confirmed, you can exit out of Single User Mode by typing exit or reboot. The Mac will now boot as usual and you’ll have access to the machine with the new password.

This is an easier and faster method than the approach taken for resetting lost passwords or using the Mac OS X boot DVD, because it’s changing an existing root users password rather than creating a new admin user account. Both work fine though, so you can use whatever method you’d like.

You can use the same approach to navigate around a sleep/wake lock screen, although you’ll obviously have to reboot the Mac meaning you will miss whatever is currently on the users desktop.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: David Mendez in Mac OS X, Tips & Tricks, Troubleshooting

48 Comments

» Comments RSS Feed

  1. Reb says:

    nice
    bookmarked!

  2. Dan says:

    Wow! Is it really that easy to get around password protection on a Mac? That’s scary!

    • MickM says:

      What would be really scary is if you could back up the original password file, change the password, rape and pillage the machine, and then restore the original password file. I wonder if that’s possible :-(.

      • Jonathan W says:

        You can’t restore an original password using Kerbos login. You can, however, with any amount of software available online… scary stuff, but it’s protectable.

      • Gus says:

        How can you restore the original password file?
        its just a password reset at boot level – not rocket science! Just like saying “I dont have the keys to the car on me as they are locked inside but I can smash a window”

    • Jeremy says:

      yes but you can set an open firmware password which can not be bypassed at all, if you forget that you are S O L

    • m says:

      you can set a firmware password, this is more protected, but more dangures as forgetting this password woeld require opening you imac so IF you set the firmware password MAKE SURE you store it someware SAFE

    • Gus says:

      Its just a linux BSD rehashed many times.
      The theory is that if you have direct console access to a host (standing in front of the machine) then why shouldnt you be able to reset the root password. Its only our friends in microsoft that want to sell you cars with the hood welded shut!

      • TB says:

        Ever heard of the Offline NTFS Editor? It’s 3rd party, but makes it trivially easy to reset the root admin password in the SECURITY registry hive. This isn’t a Mac/Windows thing, it’s a computer thing.

        I mean, come on. It’s 2014. Can we stop with Windows v. Mac now? Apple is 100x more restrictive with the App Store than Microsoft ever was towards developers, and if the Windows Mobile Store wasn’t so much of a goddamn travesty, Windows Phone 8 would actually be a serious contender for best mobile OS.

        I miss 1996 too, but it’s time to move on.

  3. Brad Zimmerman says:

    Once someone has physical access to your hardware – game over.

    You could set a firmware password to prevent the various start-up functions (http://support.apple.com/kb/ht1352) but FWsucker can easily grab it. I believe there’s also a hardware method (adding/removing RAM and resetting PRAM) to disable the firmware password as wel.

  4. Alberto says:

    If it is so easy to enter on a Mac what is the sense to have a password?

  5. Rakotofotsy says:

    So I’m running an older imac (the swivel head) with Panther. How can I change the admin password using the SU mode? I’ve tried the above suggestion, as well as others, but nothing has worked. I’m techy, but not that techy. HELP!!!!!

  6. Chason says:

    Questions for the experts:

    This didn’t work for me on single user mode in Lion 10.7.3. when the disk has been encrypted with FV2

    Specifically, this scenario: disk is encrypted by Admin;
    Standard user (with restart privileges) restarts in SU mode, unencrypting the disk.

    However, attempting to change own or admin passed via

    passwd

    returns an unspecified error.

    Various dscl command don’t work either, returning the error that /System/Library/com.apple.DirectoryServices.plist is missing (which is indeed the case).

    I’m not sure, but I believe the issue is that with FV2 encrypted the accounts password files are not where they would be otherwise. Presumably, they must be in the Recovery partition, otherwise how could FV2 check the passwords on a normal startup?

    I’m not sure if this is right, but it doesn’t seem that from SU mode you can look at the Recovery partition either, as

    DiskUtil list

    isn’t enabled.

    Can anyone confirm any of this? Has anyone managed to reset either a user or admin password in SU mode on a Lion install with FV2 enabled?

    Thx.

    • James says:

      Hi!
      This is definitely the case.
      Once FileVault is switched on, you cannot change your password without entering the old one.

  7. Nang says:

    Thank you so much! However, I had an error when I typed “passwd user” (the shortname is actually ‘user’).
    It says:
    mount: illegal option — /
    usage: mount [-dfruvw] [-o options] [-t external_type] special node
    mount [-adfruvw] [-t external_type]
    mount [-dfruvw] special | node
    :/root# ls /Users/
    .localized Shared user
    :/ root# passwd Shared
    passwd: The daemon encountered an error processing request. The daemon encountered an error processing request.

    It is a new 27″ iMac with the latest OS but it is already registered under the name ‘user’. I couldn’t ask the password simply because of personal reasons.

    Much appreciate your help!

  8. fred says:

    Chason, Not for me either. I bought a used MacPro and the previous owner left everything on it and would not give me the passed but did later. I still have his name on everything. I thought changing the Admin Pass would fix that but no, the same probs u have.

  9. Marty says:

    This does not work for me. When I type “passwd username” it says, launch_msg(): Socket is not connected
    Passwd: Unable to open Directory node with name /Local/ Default. Node name wasn’t found.

    What am I doing wrong? Help would be appreciated. Thanks!

  10. Manjunath Mariyappa says:

    Works very well with Snow leopard. I was able to change the password for user with admin rights.

    Thanks a lot for the post ..

  11. Jim says:

    I tried it and it worked but when I logged in and entered the new password, it says “Your user account password is different from your FileVault password.” It asks for the old user account password which I can’t remember.

  12. jovanni says:

    Hey I bought a macbook (the all white ones) but i dont have the password to get into it, and i was wondering if anyone knows how to reset the password? i also dont have the disk
    that usually comes with it. Thank you

  13. Iven says:

    Why am i not able to type in the the new password…….every steps worked out perfectly but arriving at the password step…..when i type in something it doesn’t appear…..any idea???

    • Jim says:

      I am having the exact issue that after I enter the passwd username command, I receive no error, just the prompt returns. I am using OSX 10.4.11

      • I think so says:

        It doesn’t show the password; you have to type it in, press enter and then retype it, press enter and it will change the password.
        You don’t see the password as you’re typing it in.

  14. Bill says:

    Ok, I have tried the original coding listed above with no results. I have since tried the route of the following.

    mount -uw/
    cd users
    ls
    passwd username

    and changed the admin account password that you need to use to logon to the computer but apparently there is another admin account not shown in the above that prevents me from downloading any software updates from apple.

    Powerpc G5 dual processor non intel running osx 10.5.8

  15. st says:

    It doesn’t show for security reasons, just type new password, hit enter and retype to confirm, then type reboot , login with new password you created

  16. Rishi says:

    Will this work for Lion 10.7 as well?

  17. Rishi says:

    I guess for Lion 10.7 one has the option to boot into Lion Recovery and can open Terminal and type “resetpassword”

  18. Gaurav Sharma says:

    Insane! I had lost my boot disk and forgotten my own password – happens with age :)… thanks so much for this! 10.6.8

  19. Marko says:

    Thanks mate, it works!

  20. I think so says:

    Anyone know if there’s a way to reset filevault without old admin password or master password? I managed to change the admin password but now it’s giving me an error message saying that the filevault and admin password don’t match up and I need to type the old admin password, which I don’t have.

  21. catalina says:

    omg i finally found a website that could help me!!this actually worked :)

  22. Ludvig says:

    When I enter “fsck -fy” in “:/ root#” it says “disk0s2: I/O Error. ** The volume Macintosh HD could not be verified completely.”
    What’s the problem?
    Typing in “mount -uw /” doesn’t work either.

  23. Kat says:

    None of this helped.

  24. Lee Joramo says:

    I found that under Mac OS X 10.4 the passwd command did not work. It ended up being that you need to issue the following command

    sh /etc/rc

    wait a while, you will see a lot of start text scroll by. If a prompt doesn’t appear after a bit, try hitting the return key. Hopefully that will get you back to the command prompt. Then you can trying issuing the passwd command again. I found this try at http://superuser.com/a/359532

  25. Keshav Bhat says:

    What a life saver! I installed Lion and lost ability to run some critical software. Then returned to install Snow Leopard. Lost access as admin. This set of instructions were perfect. Thank you!!

  26. Jon says:

    For any Lion users having trouble with the passwd command not working in single user mode, try running this command before you run passwd:

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

  27. Power says:

    Ok, I have tried the original coding listed above with no results. I have since tried the route of the following.

    mount -uw/
    cd users
    ls
    passwd username

    and changed the admin account password that you need to use to logon to the computer but apparently there is another admin account not shown in the above that prevents me from downloading any software updates from apple.

    Powerpc G5 dual processor non intel running osx 10.5.8

  28. vmorgo says:

    So for 10.7 – 10.8.3 users:

    #1 fsck -fy
    #2 mount -uw /
    #3 launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
    #4 passwd username

    Unfortunately, this does not work with Mavericks when attempting to reset the root password. The four steps work as expected, but then when booting in to the system and attempting to sudo to root (sudo -) from the command-line, the result is still “Sorry”, even when entering the correct password.

  29. Jesse says:

    The mac I am attempting to access is a bit older (about 7-ish years old give or take) and every time I try to do this, nothing really happens. The screen claims that there is no feed (I checked the connection multiple times and it even works just fine when booted up normally) and after a few minutes the fans “kick into overdrive,” then I get nervous and turn it of. This has happened every time I have tried this method. Is there something I can check or should do differently?

  30. Aisha says:

    Lock numeric can’t login cos I have numbers as part of my password what do I do please

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates