Terminal 101: Changing Your Password with Passwd

Every Monday, we’ll show you how to do something new and simple with Apple’s built-in command line application. You don’t need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type ’em out!

Sometimes you may need to change your password while not in a GUI (graphical user interface). It may be while connected to your Mac over SSH, or perhaps while booted into Single User Mode. Either way, resetting your password with a text-only interface may seem a bit daunting at first, but this guide will have you up to speed, and changing your password in no time flat.

Resetting in OS X Terminal (or through SSH)


To get started, we’ll load the Open Directory services by typing the first command if you’re running OS X 10.7 or higher; or, the second command if you’re running OS X 10.6 or earlier:

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

Next, we’ll reset the password by typing in the following command:

dscl . passwd /Users/username

You’ll be prompted to enter the new password for the user, followed by the enter key. If the user account was previously protected by a password, then you’ll be prompted to enter the old password to get permission to change the password for the user.

You’ll want to restart your computer by typing the following command after resetting the password:

reboot