The Mac registers with a Bonjour Sleep Proxy when it goes to sleep. The Bonjour Sleep Proxy (BSP) can be an AppleTV, Apple router, or built into the ethernet stacks of recent Macs. The BSP will pretend to be the Mac and continue to advertise services. If another machine tries to connect to one of those advertised services, the BSP will send the magic packet to wake the Mac up.
One service which receives special attention is ssh, so if you attempt to ssh to a Mac which is asleep but registered with a BSP, the BSP will wake up the Mac.
In order to have this work on Linux, you would need a program on Linux that can register the linux box with the BSP when it goes to sleep. It looks like SleepProxyClient will do that:
These scripts enables your Non-Apple server (or NAS) to save energy by
going to sleep if it's currently not in use. But it will be instantly
woken up again by the SleepProxyServer using Wake on Lan (WOL) if one
of it's services is requested. See
http://en.wikipedia.org/wiki/Bonjour_Sleep_Proxy for more details.