Use your iMac as external screen for your Macbook

Just plug the Macbook to the iMac Thunderbolt port using a Thunderbolt-to-Thunderbolt cable. On the iMac, press Cmd-F2 and it switch to Screen only mode. No need to reboot the iMac.

On the Macbook, the monitor settings will allow to use the iMac as only external screen or as an extension of the Macbook screen as well as in duplicate mode (both screens showing the same).

Enjoy your Mac.