How can I reset an admin password with the Terminal?

I am using the terminal to try to reset an admin password as the standard options don’t work.


unfortunately I have some weird message which is bash-3.2# and all commands don’t seem to work in terminal.


none of the exit commands or new sessions seem to provide any sort of “reset” to try to type the passwordreset command


totally lost on this one


[Re-Titled by Moderator]

Posted on Dec 27, 2023 1:38 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 27, 2023 1:39 PM

It seems like you're in a root shell within the Terminal. The "bash-3.2#" prompt indicates you're in a root or superuser shell. To reset the admin password, try the following steps:


1. **Resetting Admin Password in Single-User Mode:**

- Restart your Mac and hold down Command + S while it's booting to enter Single-User Mode.

- Wait until you see a black screen with white text.

- Once you're at the command line (it will say something similar to "localhost root#"), type:

```

/sbin/mount -uw /

```

Then press Enter.

- Next, type:

```

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

```

Then press Enter.

- Now, type:

```

passwd [username]

```

Replace "[username]" with the username of the account you want to reset the password for. Press Enter.

- Follow the prompts to enter and confirm a new password. You might not see characters appearing on the screen as you type. After entering the new password, press Enter.

- Restart your Mac by typing:

```

reboot

```

Then press Enter.


2. **Exiting the Root Shell in Terminal:**

- If you're still stuck in the root shell in Terminal, you can exit by typing:

```

exit

```

Then press Enter. This should return you to your normal command prompt.


These steps should help reset the admin password and exit the root shell in Terminal. If you're still experiencing difficulties, consider reaching out to Apple Support or consulting with a professional to ensure the correct steps for your specific situation.

1 reply
Question marked as Top-ranking reply

Dec 27, 2023 1:39 PM in response to Broondog

It seems like you're in a root shell within the Terminal. The "bash-3.2#" prompt indicates you're in a root or superuser shell. To reset the admin password, try the following steps:


1. **Resetting Admin Password in Single-User Mode:**

- Restart your Mac and hold down Command + S while it's booting to enter Single-User Mode.

- Wait until you see a black screen with white text.

- Once you're at the command line (it will say something similar to "localhost root#"), type:

```

/sbin/mount -uw /

```

Then press Enter.

- Next, type:

```

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

```

Then press Enter.

- Now, type:

```

passwd [username]

```

Replace "[username]" with the username of the account you want to reset the password for. Press Enter.

- Follow the prompts to enter and confirm a new password. You might not see characters appearing on the screen as you type. After entering the new password, press Enter.

- Restart your Mac by typing:

```

reboot

```

Then press Enter.


2. **Exiting the Root Shell in Terminal:**

- If you're still stuck in the root shell in Terminal, you can exit by typing:

```

exit

```

Then press Enter. This should return you to your normal command prompt.


These steps should help reset the admin password and exit the root shell in Terminal. If you're still experiencing difficulties, consider reaching out to Apple Support or consulting with a professional to ensure the correct steps for your specific situation.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can I reset an admin password with the Terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.