The best way to avoid getting viruses is to install an anti-virus software that will protect your computer against these threats. Other best practices to prevent an infection include thinking before you click. If a website provides pirated material, avoid it. If you get an email attachment from somebody you don’t know, do not open it. If you get an unsolicited email, do not click the links within the email. Scan files you have to download from the internet before you run them (a good anti-virus software should do this automatically, but double check it is being done).