In the early days of OS X, a lost password was a significant issue. Before the introduction of the Mirrored Door Drive Power Mac and machines shipping with OS X as the default boot system, should you forget your password you had significant problems. When Macs first shipped with OS X as the default boot volume, Apple added to the install media an application that would allow you to change a user’s password.

With the launch of Lion, we are faced with a similar issue. Lion machines come with no physical media. All units with Lion on them are configured with a recovery partition on the hard drive that includes few options. If you are having an issue with your Mac, you can use this partition to boot the unit and launch Disk Utility, the network-based installer, Safari and a few other options. Missing from the recovery boot is the password reset utility.

So if you forget your admin password, how do you change it? In all versions of OS X once a User has been created, a file called .AppleSetupDone appears and is located in /var/db. If you boot the machine to single user mode by holding down command key and the letter ‘S’, you can mount the file system and remove this file.

Power the unit holding down command key and ‘S’
type mount -uw /
Change directory, cd /var/db
Remove the file, rm .AppleSetupdone
Exit single by either typing exit or restart with reboot.

When the system restarts you will run through the entire setup as if the unit was brand new. Creating a new user account will give you access to the machine as an administrator.

After creating this new user account, you will be able to open System Preferences and select Groups and Users. Then, after unlocking the the Preference Pane, select the User account you wish to change the password for and select Reset Password. As always, when you change the password for a User, whether it be with the Password Utility from install media or via this route, make sure you rebuild the keychain. You will have to authenticate for each service as you launch it until the new password is in your new keychain.