By far the most common way a computer can be infected with a virus is by transferring virus code (which is a program) onto the target computer and execute that code in an unrestricted manner. It is a security risk anytime program code from an unknown source is executed on your computer.
There are four primary methods of transferring virus code onto a computer:
1. Through an email with virus code attached.
2. Through a malicious web page.
3. With a program that pretends to be useful but is in reality malignant.
4. Taking advantage of a network security flaw in the operating system of the computer.
1. In the case of an email, if the recipient executes the attachment the virus code runs and infects the computer. Since Windows often hides file extensions a virus file named 'FunnyVideo.exe (which is an executable file) only shows up as 'FunnyVideo', which looks harmless. Virtually all antivirus programs and web based email sites (such as gmail, hotmail, yahoo, etc.) scan emails for malicious code. Webmail sites often refuse attachments with executable file extentions such as .exe to help limit virus transmission.
2. Did you know your computer is running programs automatically downloaded from websites? Including this website? As I write this each key stroke is not being sent to this website but is actually being recorded by a text editor program and will be sent to the website when I click the [Submit answer] button. One of the great unsung advances in web browsers is their ability to be programed from a modern website.
This is largely due to a programing language used on web pages called Javascript. Javascript is unrelated to the programming language called Java, however they both can be used in a web page. Both Javascript and the Java programing language are tightly restricted in what they can do in a browser and cannot normally access anything outside the browser. However, there have been numerous security faults in web browsers, most notably Microsoft's Internet Explorer, which have allowed Javascript or Java programs access to download and run malicious code on the target computer in an unrestricted manner. Simply visiting a malicious website (without even clicking on anything) using an older, unpatched browser can infect a computer due to known security flaws in the browser.
3. Unfortunately, there are many programs that claim to find and remove malicious software such as adware, spyware, malware, and viruses but what they actually do is to remove some and install others. Some are add on browser search bars, games, coupon offers, the list goes on and on. It pays to be vigilant when downloading and installing any software. If it sounds too good to be true it probably is.
4. Anytime a computer is directly connected to the internet it is bombarded with all kinds of undesirable traffic. If some of this traffic finds a chink in the armor of a computer it may take advantage of it by infecting it with a virus. Security problems in operating systems are taken advantage of in many different ways to directly infect a computer with a virus without any action on the part of the computer user.
The best way to prevent infection of viruses, adware, spyware, or malware of any sort is, in case:
1. Use an antivirus program. There are many good free antivirus programs out there. The best know antivirus programs are not always the best. Don't run an email attachment from an unknown source.
2. Don't use Internet Explorer. I'm sorry to say it has a terrible security track record. There are many good web browsers out there now that are both faster and more secure than IE, including Firefox, Opera, Google's Chrome, and Apple's Safari. Regardless which browser you use, keep it up to date with it's security updates.
3. Don't download and run every free program on the internet. I'm going to repeat myself: It pays to be vigilant when downloading and installing any software. If it sounds too good to be true it probably is.
4. Keep up to date with security patches to your operating system. Use a firewall, this will help prevent malicious internet traffic from accessing your computer. Don't directly connect a computer to the internet, use a router. This will not only allow you to connect more computers (and add wireless access) but provide a sort of 'clearing house' for incoming network traffic. Due to the way a router works any incoming traffic the router doesn't recognize as intended for a local computer is simply dropped.
Taking these steps helps to protect a computer running any operating system, whether it's Mac OS, Linux, and especially Windows.
http://www.answerbag.com/q_view/1874795