Reset your Mac to default settings
If you're planning to sell your Mac or simply give it to a friend or some other member of your family, you should first restore it to its default settings; that will ensure your security in case a stranger gets it and it makes it feel brand new for the future owner, which is always nice. Unfortunately, the process of eliminating your traces from the device is actually more complicated than you would expect. Here's a short guide on how to reset your Mac to default settings:
Before we begin, you might want to consider making a clone of your current hard-disk which will make it easier for you to set up a new Mac. If you want to do that, I recommend Carbon Copy Cloner, but you could also use a tool called SuperDuper! that's also really good. Additionally, in case you want to leave the device in perfect working order, you will also require an Internet connection to download the installer for the operating system once you're done erasing stuff.
Now that the preparations are over, the first step that you need to take is to sign out of every account you own. Begin by deauthorizing and signing out of iTunes: go to Account-->Authorization and select De-authorize This Computer (you will need to provide your Apple ID and password in order to do that), then click on the Sign Out button from the Account menu. You should also disable the File Vault in case you have it on. Go to the Security & Privacy section in the System Preferences, click on the File Vault tab and make sure that the feature is turned off.
Since you're already in the System Preferences menu, open the iCloud application, remove the check mark from the Find My Mac option, then select the Sign Out Now option and instruct the application to delete your data each time it prompts you for it. Lastly, you should also sign out from your iMessages account.
Now that you're done with the "finesse" settings, restart the device and go into the Recovery Mode by keeping the Command + R keys pressed while the device is rebooting. In the menu that shows up, choose the Disk Utility option, press the Continue button, then select your drive, which by default will be named Macintosh HD and click the Erase button. This will completely wipe the entire disk, so you'd better be sure that you have backups of your important files. Additionally, you can also select the Mac OS Extended (Journaled) entry and erase that one as well. Press the Quit Disk Utility button to return to the previous menu.
Lastly, select the Reinstall MacOS (or Reinstall OS X if the device is older) option and follow the instructions to reinstall the operating system that came with your Mac. In case you're being asked for your Apple ID and password, quit the installation process and let the new owners enter their own credentials.
Before we end things, you should remember that deleting your traces from a Mac that you're giving to someone else is actually more important than preserving your online privacy, so it's a step that you really shouldn't skip.