There's only two ways to get a virus on Linux and I suspect a MAC as well seeing as it's Unix based. The first way is if you, the operator, gives permission to execute a program to run which is downloaded from a web site, which is a really stupid thing to do. The core files in a Linux machine are read only, they can only be modified by root admin using a password, I haven't used a MAC but I suspect they are the same.
The other way is though an application, say Firefox or Java. If one attacks an application then just delete the application and all the config files and the nasty vanishes, not much good for a hacker who wants to install a nasty.
Incidentally, hackers love to get control of Linux machines if they can, they install malware on them because a Linux can handle loads much better than a Windows machine, the Linux box won't slow down like a Windows machine. They also like to protect their investment by installing software to protect them against attacks from other hackers. That's why it's so important to make sure you use good password protection and being very careful when using the root commands, and never, ever install anything just because something asks you to on the internet.