I am using my iMac 2017 5k as my main machine and want to use my 21 inch 2017 iMac in target display mode. When I try command f2 I hear a beep and nothing happens. I have also tried doing it at the login screen and also tried fn command f2 but nothing worked. What am I doing wrong? Is this possible?
Neither of your Macs support target display mode. Below are the Macs that do.
iMac (27-inch, Late 2009)
iMac (27-inch, Mid 2010)
iMac (Mid 2011-Mid 2014)
For more information see Use your iMac as a display with Target Display Mode.