You may start to freak out if you ever forget the password to log into your iMac or MacBook, but it's really not that big of a deal. All Macs include a built-in password reset tool that is incredibly easy to use.
To get started, you will need to restart your computer. Press the Command and R keys at the same time when the grey screen appears and hold them until you see the Apple logo. A small loading bar will appear under the logo. Sit tight as your system boots into Recovery Mode.
Click the Utilities tab in the top menu bar, select Terminal, type resetpassword and press Enter. Close out the Terminal window and behind it you will find the Reset Password utility. All you have to do now is select the user account you want to reset, enter a new password or leave it blank and click Save. Then just simply restart the computer from the Apple menu and login with your new password. It's as easy as that.
This method is very useful if you ever forget your password or if you need to get into a child's password protected computer. It can also be used, however, for malicious purposes. Here's how you can protect against that from happening.
A nefarious individual could purloin your Mac and bypass your user account password in order to access your data or wipe your system clean and begin using it as their own. It's possible to reset a password by booting into Recovery Mode or from an external drive.
Thankfully, there two precautions you can take to protect yourself and your Mac from intruders. One is a software-based encryption tool, and the other is a hardware-based encryption tool, both of which are built-in utilities of OS X. The software tool is a utility called FileVault, which you may already be using. The hardware tool is a firmware password you can set in Recovery Mode.
FileVault Disk Encryption
FileVault encrypts the data on your Mac so unauthorized users can't access your files. If you are using OS X Yosemite, then you are likely already using FileVault. When you installed Yosemite, one of the setup screens asked if you wanted to enable this utility.
To check to see if you are using FileVault, open System Preferences, click Security & Privacy, and then click the FileVault tab. To enable FileVault, click the lock in the lower-left corner to unlock it and enter your admin name and password. Next, click the Turn On FileVault button.
Screenshot by Matt Elliott/CNET
You'll get a recovery key, which you'll need if you want to reset your password. Be sure to keep this recovery key in a safe spot. Alternatively, you can store it with Apple. If you choose the latter, you will be asked to create three security Q&As -- three hoops to jump through should you need to ask Apple for your recovery key in the future.
After a restart, FileVault will begin to encrypt the files on your drive. You can still use your Mac while FileVault works in the background, though its performance may be a bit sluggish.
Even with your files encrypted with FileVault, someone could grab your laptop, enter Recovery Mode and wipe your hard drive clean and start fresh. While this keeps your files from prying eyes, it certainly doesn't prevent a thief from happily using your Mac after a fresh install of OS X. A firmware password is a hardware-based encryption tool that requires a password when booting to Recovery Mode or from an external drive.
To create a firmware password, you will need to reboot your Mac and enter Recovery Mode by holding down Command-R when it begins to boot up. When the OS X Utilities screen appears, click on the Utilities menu in the menu bar and select Firmware Password Utility. Next, click Turn On Firmware Password, enter a password, and click the Set Password button. Finally, click Quit Firmware Password Utility, and choose Restart from the Apple menu in the upper-left corner.
One word of caution: make sure you don't lose track of your firmware password. If you forget it, you will need to take a trip to your nearest Apple Store to reset it.
(Via How-To Geek)