Mac OS X recover lost root password

Contributor Icon Contributed by macster Date Icon September 25, 2004  
Tag Icon Tagged: Apple Mac

For the sake of security, recommendations say to have unique, complex passwords. Most people have a hard time remembering these and will eventually forget one. Forgetting the root password on a Mac system can seem devastating, but this recipe will show an easy way to recover.


If you have the password to an account that is an administrator on the system, then it is easy to recover the password using the sudo command. Open a terminal window and type:

sudo passwd root

and you will be prompted for your password (the user account that you do remember). Then you will be prompted for the new root password twice. That’s it!

The sudo command is a wonderful way to control who can do what on a system. In this case, since the user account is considered an administrator, the sudo command allows you (after confirming that you are who you say you are with the user password) to run a command as if you were root. The command we are running is passwd root which is the command to change the password for the root user.

If you do not have an administrator password, either, you can still reset the root password. Boot the system from the Mac OS X installation CD and select the Reset password option from the installer screen and follow the directions.

Previous recipe | Next recipe |
 
  • miamiman
    Hello, I recently bought a apple g4 laptop , and do not have the password to unlock ....what can I do as I do not have the reinstall disc to boot from? Also, do i type in "sudo passwd root' or "passwd root" only? Thx very much. I enjoyed discovering this site...
  • qmchenry
    Do you have the password to an account on the system that is an administrative account? Only those accounts can use sudo (which is quite the cool, recipe-worthy command when I or someone else has the time). Sudo is essentially a way to prevent users from having to become the root user to do root user activities. Many people tend to log into unix systems as root with all the gui weapons -- I mean tools -- at their disposal, ready to wipe out their system. It's a nasty habit, one which makes a unix system one step closer to a windows box. Speaking of boxes, I'll get off my soap one now..

    If you have an account that is privileged (can use sudo), and there can be several on a system, then you can login as that user and use the sudo passwd root command. The password it will ask you for is the current, privileged user's password. Then it will ask for the new root password twice and you should be set. If you do not have an administrative account, let me know.. there are other ways....

    Q
  • check
    im having this problem...im stuck on a non-admin account and I lost my admin password...on top of that...my disc drive doesnt seem to work...and my os x disc will not boot from my external dvd drive....
    what can I do?
    thanks
  • qmchenry
    This worked for me on 10.3:

    Restart the system (Apple menu -> Restart)
    Hold down Command-S while restarting -> lots of white on black text
    From the command prompt issue these commands:

    mount -uw /
    /usr/libexec/register_mach_bootstrap_servers /etc/mach_init.d
    netinfod -s local
    SystemStarter
    passwd root



    I believe that in some other versions of OSX, the second and third steps are not required because SystemStarter configures networking in those versions. In 10.3, several services will not start without active networking including opendirectory which stores the passwords.

    If you get to the command prompt and run 'passwd root' and it sits for 10-15 seconds and then returns to a command prompt, this is indicative of a timeout waiting for connection to a service that is not running. If you didn't do all of the steps above, try them in that order and see if that helps.

    Q
  • check
    thank you for your help...going to try it now...but even if it doesnt work I appreciate it greatly!
  • check
    the SystemStartup seems to freeze the computer while searching for something called "ARDAgent.app"
    not sure what that's all about
  • qmchenry
    Sorry that didn't work.. what version of OS X are you running? There should be a way to prevent that service from starting. There may also be an easier way for your specific version.
  • cbk
    Same problem....stuck on a non-admin account, lost admin password....disc drive not working.......OS X will not boot from external dvd drive.....we are using Panther not 10.3 - will those instructions still work? Thanks.
  • asp
    How do I check which version of mac os I have? I am really new to mac sorry, I have the same problem. For me when I sent in my powerbook for repairs, it returned with a changed admin password.
  • Anonymous
    1. boot computer and hold the "apple" key and the "s" key.
    2. wait for terminal show
    3. release keys
    4. type without the quotes: "/sbin/mount -uaw"
    5. press enter
    6. type without the quotes: "rm /var/db/.applesetupdone
    7. press enter
    8. type without the quotes: "reboot"
    9. press enter

    this will let you create a new admin account when you reboot your computer.
  • davak
    I'm not an apple guy, but this seems like a great recipe!!!

    If you want to post it as a new recipe, I'll run it by our apple moderators and see if we can get you a fat amazon gift certificate reward!
  • Anonymous
    This does not "recover" anything; it would be more appropriate to say it "resets" or "changes" the password.
  • Anonymous
    i have ibook g4 bought it off of ebay the user is no longer a registered user so i cannot contact them to get the password so i bought a new os it is 10.2.4 when i start and try to reinstall it says i need the password i tried taylors way and qms way neither would work i know i done taylors way correct i know but i dont know about qms tell me if this is correct
    hold apple button by the spacebar and s upon boot
    type mount -uw / enter
    type /usr/libexec/register_mach_bootstrap_servers /etc/mach_init.d enter
    type netinfod -s local enter
    type SystemStarter enter
    type passwd root enter

    is all this correct


    im wanting to delete everything and install this new any way possible
    i appreciate any help i can get if there is anyone willing to talk me through this i might slide a little dough there way hit me up robertseber@yahoo.com any time thanks
  • Anonymous
    it currently has mac os x 10.4.6

    sorry i am new to a apple
  • Anonymous
    it currently has mac os x 10.4.6

    sorry i am new to a apple
  • Anonymous
    The command s/mount/rm/reboot sequence worked perfectly on osx 10.4.8

    OSX filenames are case sensitive, and the file on my machine was:
    /var/db/.AppleSetupDone
    :D
  • Anonymous
    Hmm i tried the "passwd root" command and at the end it came up with NetInfo write failed: Remote system error. Any ideas on what to do?
  • Anonymous
    <ul id="quote"><h6>taylorchase wrote:</h6>1. boot computer and hold the "apple" key and the "s" key.
    2. wait for terminal show
    3. release keys
    4. type without the quotes: "/sbin/mount -uaw"
    5. press enter
    6. type without the quotes: "rm /var/db/.applesetupdone
    7. press enter
    8. type without the quotes: "reboot"
    9. press enter

    this will let you create a new admin account when you reboot your computer.</ul>

    These are great instructions, thanks! This just worked for me!
  • jason myers
    this not only worked on the password problem but i never had to reload any programs thanks a million!!!!
  • Manda
    Will this work with filevault active?
  • rex2930
    I realy need your help i am getting frustrated badly step 1 to 5 works fine but when i try to do step 6, is says the following rm/var/db/ : no such fle or directory wth am i doing wrong Please write back ASAP
  • thomas bowen
    Daughter has only one account on Mac and doesn't remember her password. I can't load any new software. Any help? I tried the sh /etc/rc then passwd username it prompted me for a new password. I typed in the new password but nothing actually typed. It asked me to repeat it (even though nothing actually appeared) I typed in what I had the first time typed in reboot and after it rebooted, I went to daughters account tried to get in, but it said we didn't have the right password. A little help would be nice. Thanks
  • Nikki G.
    OK I have a MAC OS X
    Lost password
    NO administrator account
    Only One
    Can't find software
    HELP
  • kathy
    Wow thank you so very much! It worked the very first time!
  • les
    i lost my disc.s for back up and for got pass word to get in to my mac g4
  • jB
    Bad Title!
    In no way does this recover the lost password!
    It is useful for resetting the password.
    Important difference.
  • Ad
    Hi Can anybody help me? I couldnt remember my password to my ibook so i used this 1. boot computer and hold the "apple" key and the "s" key.
    2. wait for terminal show
    3. release keys
    4. type without the quotes: "/sbin/mount -uaw"
    5. press enter
    6. type without the quotes: "rm /var/db/.applesetupdone
    7. press enter
    8. type without the quotes: "reboot"
    9. press enter
    which worked great but when i got into my ibook everything that was on it had dissapered!! can anybody tell me how i can get the photos and music back that is on the system somewhere my hard drive is only showing 5 gig available and im about 9gig missing if somebody could tell me how to access these files i would me most gratefull Thanks
  • rex2930
    how do u no wth version of Mac Window base do u have i currenly los my passwork and my master password but tried everything wth u guys had down there Mac OS X 10.4 but do u do that if u cant get into your on Mac
  • thank you very much, your instructions worked a treat.

    i was trying to delete some files that were locked and hidden inside an app. v frustrating for a control freak like me. now very happy your simple instructions allowed me to change the root password, which i had forgotten. still wondering what it was... ???
  • Mohit
    Thanks a lot . i helps. I was able to change my password. I am really new to mac and linux, so dont know so many commands
  • eliza6226
    I have a Mac Mini with OSX 10.5.6.

    I have an admin password, and used your recipe to obtain another root password. However, when I try and log in the a new terminal window with the new root password it says "unknown command"

    What have I done incorrectly?
  • Matt
    If my MAC is stolen how does this prevent anyone with a leopard disk from recovering my password for my file vault account?
    ie: change root password, then change account password, then login, and steal company files?
  • Erkan
    Hi I can not acces command s . And forgot password and master and don.t have installation cd. Is there any diferent way ?
  • thomas
    i just baught this cpu and i dont have the cd but there is a password on it that i dont know what it is every time i try to download any thing it asks for it but i havent the foggiest. if any one knows how to get rid of this or knows any thing about these cpus please help im now ofically lost. please help me
  • I can not start my G4 lost the password OS
  • well this is quite a simple one and might not work for you, but if you have any other account on your mac( admin) then you can simply
    1. go to system preferences
    2. select the user from the left sidebar
    3.click reset password.
    4. it will ask you for a new password.
blog comments powered by Disqus