Change the Admin Password with Mac OS X Single User Mode

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:
- The next command mounts the root Mac OS X drive as writable, allowing you to make changes to the filesystem:
- After the filesystem is mounted, you can reset any users password using the following command:
- You’ll need to enter the new password twice to reset and confirm the changes
fsck -fy
mount -uw /
passwd username
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.

nice
bookmarked!
Wow! Is it really that easy to get around password protection on a Mac? That’s scary!
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
.
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.
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
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
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.
If it is so easy to enter on a Mac what is the sense to have a password?
To prevent unauthorized remote access using SSH or other protocols.
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!!!!!
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.
Hi!
This is definitely the case.
Once FileVault is switched on, you cannot change your password without entering the old one.
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!
Hey man – Im receiving the sa
E error(s). Did u happen to get a response?
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.
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!
Works very well with Snow leopard. I was able to change the password for user with admin rights.
Thanks a lot for the post ..
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.
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
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???
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
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.
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
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
@jim
Will this work for Lion 10.7 as well?
I guess for Lion 10.7 one has the option to boot into Lion Recovery and can open Terminal and type “resetpassword”
Yup, this is correct.
Insane! I had lost my boot disk and forgotten my own password – happens with age
… thanks so much for this! 10.6.8
Thanks mate, it works!
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.
omg i finally found a website that could help me!!this actually worked
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.
None of this helped.
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
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!!
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
This worked great.
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
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