How to reinstall OS X on an iMac which only has Ubuntu installed on it?
I have installed only Ubuntu. it warned that i may not be able to recover. However, if you hold Alt (option) key since the booting, it will prompt you to select a Wireless network (so make sure there's one available). Once connected it will ask you to confirm on Internet Recovery Mode. Select the option and proceed. This will take a while, so be patient.