I overwrote mac OSX with linux and I can't change it back to OSX because I cannot boot to the apple recovery mode it only boots to linux so I am not able to reinstall Mac OSX or windows.
Since your Mac is from 2001, It most certainly won't run anything past Leopard (10.5) and may not even run Leopard (If it doesn't, then it would run Tiger (10.4). Regardless, you will need an installation disc for this appropriate version. Follow the instructions that come with the installer to install from the disc.
Recovery mode is persistent on newer Macs, but can be erased on older ones.
A circa 2001 iMac can run OS X Tiger 10.4.11 at the latest. You'll need installation media to boot the system. As well, the Linux installation will have partitioned and formatted the HDD in a fashion that OS X will not be able to use. As such, the very first step after booting to the installation media will be to run Disk Utility to remove and re-create the partition on the HDD. Once that is done, format the HDD as HFS+. After the HDD is successfully partitioned and formatted, the OS X installer will find a suitable installation target and your installation should proceed as normal.