I am trying to reset the admin password through command line. Below command used to work till High Sierra:

sudo dscl . -passwd /Users/admin new_password

But on Mojave it throws an error saying:

Permission Denied please enter old password

Please help on alternatives or how to get this working on command line (no UI solution) since the user forgot the admin password. Thanks

  • 2
    How did you run sudo without an admin password?
    – dan
    Commented Jan 10, 2019 at 15:10
  • it was added once through launchctld and running through in background which doesn't ask for sudo password Commented Jan 11, 2019 at 4:31
  • 1
    The fact that this used to be possible is pretty scary IMO. I'm sorry for your situation, but this seems like a very positive change. Commented Feb 12, 2019 at 17:01

2 Answers 2


You can reset the password in Mojave by entering recovery mode and using the "resetpassword" utility via the terminal:

  1. Boot your Mac while holding CommandR. When you get the Apple logo release the keys and allow the Mac to come up in Recovery Mode.
  2. When you get to the macOS Utilities dialog select Terminal from the Utilities menu
  3. Type resetpassword into the terminal window. In a few seconds the reset password utility will open and allow you to reset the password on your account.
  • thanks for the answer Steve, but the issue we have is we are running this script remotely on other machine which would happen seamlessly without user intervention. Is there a way to access resetpassword in normal login? Commented Jan 10, 2019 at 14:28
  • I believe that command is available only in the recovery environment. Not sure if you can access that partition and run commands on it from macOS Commented Jan 10, 2019 at 16:44

It did change with the Supplemental Update you have to pass the old password, command run as root, with ot=the old password and t=the new password, for the account

dscl . -passwd /Users/account `echo "${ot} ${t}"`

We generate the to and t variables in a script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .