How to get a residence permit in Turkey!

What is a residence permit (in Turkish ikamet) in Turkey?
How many types are there?
What is needed to obtain a residence permit?