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)

launchctl load /System/Library/LaunchDaemons/com.apple.opendirectoryd.plistlaunchctl 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

Resetting In Single User Mode

If you’re not able to start your computer and load OS X’s interface (or SSH into your system), then you’ll need to start up your computer in Single User Mode (hold Command + S while booting).

Next, perform the following steps in order to reset your password.

Mount your file system by typing the following command and pressing enter:

mount -uw /

Next, 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.plistlaunchctl 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 a new password; follow the on-screen prompts to complete the password reset.

Finally, restart the system by typing the following command:

reboot


Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author on Twitter.