If you have lost your password or if you have inherited one without password, you can try following procedures to regain access to your computer.
Change the password in single user mode
- Hold ⌘+S on startup
- mount -uw /
- launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist
- dscl . passwd /Users/username (without a trailing slash) and enter a new password. You can ignore the error about com.apple.DirectoryServices.plist.
- reboot
Create a new admin account
- Hold ⌘+S on startup
- mount -uw / (fsck -fy is not needed)
- rm /var/db/.AppleSetupDone
- reboot
- Go through the steps of creating a new account. You can leave all fields in the personal information step blank.
- After logging in to the new account, go to the Users & Groups preference pane
- Select the old account, press the Reset Password... button, and enter a new password
Restart and enter Recovery mode (for 10.7 Lion and newer OS only)
- Hold ⌘+R on startup
- Open Terminal from the Utilities menu
- Type resetpassword and follow the instructions