How to reinstall OS X on an iMac which only has Ubuntu installed on it? I have a 2011 iMac with only Ubuntu installed. It's not a dual-booted iMac, it only has Ubuntu installed.

How do I revert back to original OS X and remove Ubuntu? I've tried pressing various keys (⌘ Command R, Alt, etc.) to enter the boot menu,  but so far it hasn't worked.
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.