Remove everything from Mac and reinstall OS X
You don't necessarily have to remove everything to repair OS X

Depending on OS X version you can just reboot holding the R key, to boot into the recovery partition. Alternatively you can hold alt/option to display current boot options and select your recovery partition.

Once in the recovery partition, you can use Disk Utility to erase your OS X partition if you want to wipe everything, or you can just select "Reinstall OS X" from the main menu. This will reinstall OS X system files and leave your home directory, settings, documents, etc alone. I'd recommend trying just the reinstall of OS X first, and if this doesn't work to fix your issue, proceed to erase your OS X partition and then reinstall OS X.