This will return the computer to the original state when first taken out of the box: What to do before selling or giving away your Mac. If you just wish to re-install OS X then you have two basic options: 1. Reinstall without erasing the drive; 2. Erasing the drive then reinstalling.
Reinstall El Capitan Without Erasing Drive
Please be sure you back up.
- Restart the computer. Immediately after the chime hold down the Command and R keys until the Utility Menu appears.
- Select Disk Utility and click on the Continue button.
- Select the indented (usually, Macintosh HD) volume entry from the the side list.
- Click on the First Aid icon in the toolbar. Wait until the Done button activates, then click on it.
- Quit Disk Utility and return to the Utility Menu.
- Select Reinstall OS X and click on the Continue button.
Also, see this User Tip: Basic Steps for Upgrading OS X.
Install Yosemite or El Capitan from Scratch
Restart the computer. Immediately after the chime hold down the Command and R keys until the Apple logo appears. When the Utility Menu appears:
- Select Disk Utility from the Utility Menu and click on Continue button.
- When Disk Utility loads select the volume (indented entry, usually Macintosh HD) from the side list.
- Click on the Erase icon in Disk Utility's main window. A panel will drop down.
- Set the Format type to Mac OS Extended (Journaled.)
- Click on the Apply button, then wait for the Done button to activate and click on it.
- Quit Disk Utility and return to the Utility Menu.
- Select Reinstall OS X and click on the Continue button.
[Permission to use part or all of the above has been granted by Kappy, exclusively, to theratter.]
Both of the above assume that you can start the computer from the Recovery HD.