How can I download and install software and make sure that it is not infected with viruses, malware or a keylogger?
Also, I heard that Macs "don't get viruses". Is this true? Is it a good practice to run virus software on a Mac?
Nope it's not true, by design Mac has a better security model than Windows, but that doesn't mean it's secure. Furthermore due to the market share of Apple growing more and more chances are that Mac will get more interest from attackers than they currently have due to the growth of potential targets.
There have been virusses for Mac in the past like the Trojan BackDoor.Flashback which specifically targetted a Java exploit within OS:X.
I would indeed run anti-virus software on your Mac, it provides an extra layer of defense.
First, it's not true: Macs and any other OS can get viruses. Just few viruses are written for mac.
Yes, it's a good practice to run antivirus software on a Mac.
How to download and install software that isn't infected: in general, you get good software from good sources, and checking that the software you just download wasn't tampered with (man in the middle attack). For example, checking if the MD5 checksum is the same the site published.
You just could be sure that the software is free of bugs, keyloggers, virus, etc., if you are able to inspect the source code, and know how to do it, since there are some techniques that can make malicious code less evident.
And you would also need to trust that Apple made the Mac without virus, keyloggers, and etc. And that it didn't allow NSA put any backdoor inside it. And that no programmer could make it inside the OS. And that the chips manufacturers (not only the processor, but almost every chip used inside) didn't include some hardware trojan, keylogger, etc.
I'll do my best to deal with your first question, since people mainly discussed the second and third ones you asked--and respectfully those are simple matters of fact, and subordinate logic. Yes you can get malware/viruses (it is increasingly common, much more than Apple wants to admit), and therefore yes you want to protect yourself from that stuff.
Don't use USB drives on a lot of different machines. They are an increasingly common vector for infection. In fact, try not to use them. There are methods of sending large files and the internet is pretty fast. If you can email it to yourself, do it. With email, you can be sure that nothing is piggybacking on the drive; and your email client should run some antivirus on the file itself. So that's better.
Don't charge your phone from your home computer's usb drive. Phones are increasingly affected by viruses, just from browsing on 4g networks, and can transfer them to your machine nowadays. You can back your contacts up on the cloud, if you have some data-driven desire to connect the two devices. Take advantage of the cloud, and your much-faster charging wall charger.
If you feel the need to use your home computer or (much worse) your work computer to charge your phone on your desk, then come home, and plug that into your home computer... perhaps consider buying a nifty data-only usb adapter from Amazon. Documents at work get passed from hand to hand, inside and outside the company... yeah the local network can be full of problems... and IT departmetns tend to be behind the 8 ball on security. You can't even necessarily install things on a work computer, to even make sure that it's kosher. Yeah. This is an idiot proof solution.
Malware: no one program works best. As in the PC Universe, you need to run a few to catch everything reliably. I like Adware Medic (and apparently so do Apple Support folks from my troubleshooting sessions) and BitDefender's Adware Removal Tool. They have each caught programs the other one missed, and they are super lightweight-fast, and free.
Anti-Virus. Just like with Malware, you want to use more than one program. I can't actually recommend two. I have a half dozen, and I don't like most of them. One which I would use is ClamAV. It's not rated the best by reviewers (maybe because nobody is paying them to review it well), but in my exprerience, it has caught more infected files than the other ones. If you download the version from their website, you can schedule it to auto-update and auto-run--for some reason the mac store version doesn't seem to have this feature.
Sleep your screen when you leave your desk, and set it to require a user password after a few seconds of sleep (System Preferences --> Security & Privacy). Also, under Power Settings, set your computer to go to sleep after it is idle more than a few minutes. This will cover you decently, if you walk away from your machine in the office, and forget to sleep it.
Install/use Caffiene to toggle the sleep/lock behavior on and off, when you want to watch a movie or need to give a presentation. It's easier. And easier than manually changing the time-to-sleep when you need to do it, and therefore you're way less likely to get fed up safe practices and switch your sleep time back to "never."
You don't have to be a ninja about it. But you can take note of running processes in the activity monitor, and google new ones that pop up with fair ease. You would do the same thing on a PC really...
If you really need to be certain that you don't have some kind of keylogger (some companies install them on work machines and you're not necesarily allowed to remove them), you will probably need to pick up some familiarity with the terminal. Which is a whoooole different topic. $Man ps. and... well, take things from there lol.
Only download softwares which you find an
sha1 checksum available on a publicly visible server and whith a clear timestamp.
Hence if the software was corrupted (by whatever you imagine) then it is very easy for anyone to detect this corruption. Such a corruption will be brought back to the attention of the editors within less than a few hours.
If you can't find such a publicly visible checksum, just download softwares from editors who are providing them through
https:// and moreover from editors who explain publicly how they do protect their internal servers from attacks. (An
https:// download of a virused software is a sure way to get an intact virus).
Mathematically wrong. Their software is of varying quality, sometimes much better than many, sometimes the other way around. MacOS X is based on a rather strong solid OS: FreeBSD, but the GUI added on top is including too many functions to maintain a high quality level. Too many functions mathematically increases the probability of internal weaknesses. MacOS X is simply conceived by human with the same probability of comitting errors. Even quality controls may contain errors.
Yes this is clearly a good policy: an anti-virus on any computer.