You could also say that the virus must do this without the permission or knowledge of the user.
A virus can do anything that other programs do. The only difference is that it attaches itself to another program and execute secretly when the host program is run .once a virus is executing it can perform any function, such as erasing files and programs.
Our virus definition is very general and covers all viruses. Let's consider specifically how this works. Viruses are programs just like any other on your PC. They consist of instructions for (what I like to call "code") that your computer executes. What makes viruses special is that they do their "job" by placing self-replicating code in other programs, so that when those other programs are executed, even more programs are "infected" with the self-replicating code. "Self-replicating code" is simply a program that copies itself to other programs. This self-replicating code, when triggered by some event, may do a potentially harmful act to your computer--but this is strictly optional. Only a minority of viruses contain deliberately destructive code. You could say that viruses are distributed in the form of a Trojan. In other words, the virus code has been planted in some useful program. Since the virus infects other useful programs, absolutely any piece of executable code can suddenly become a Trojan delivery vehicle for the virus.
Another way of looking at viruses is simply to consider them to be a program which can create copies of itself. These copies are inserted in other programs (infecting these programs). When one of these other programs is executed, the virus code (which was inserted in that program) executes, and places copies of itself in even more programs.
You'll notice that I used the word "attach" in our definition of a virus. This is because viruses can "attach" themselves to a program without directly modifying that program. This might seem hard to believe at this point, but I'll explain later exactly how they accomplish this trick.
When you consider our definition of viruses, it's important to understand that "programs" may exist in places that you don't expect. For example, all diskettes contain boot sectors which are "programs" that are executed when you boot your PC and Microsoft Office files (such as MS Word Documents and Excel Spread Sheets) can contain macros which are "programs" that can be executed when you open these files.