When used to denote animals, a bug is usually used to refer to any small, terrestrial arthropod, sometimes taken to include creatures like snails and slugs as well. One particular group of insects, the Hemiptera, are called the true bugs.
Since such insects are usually irritating and frustrating (mosquitoes, flies and cockroaches being prime examples of this), this word has also come to refer to something which is irritating or frustrating. For instance, a person might say someone (or a problem) is "bugging" (irritating or frustrating) them.
This term is also often used in a computer context, to refer to a computer program which is frustrating them. The most common usage of this is when a computer program does not perform the function that it is supposed to, while the error in its programming cannot be found. See computer bug.
Since it refers to small animals, the term bug is also occasionally (and inaccurately) used to refer to microscopic life forms. Somebody might refer to have caught the "pneumonia bug", for instance. A further extension of this meaning is to small surveillance devices. This can be seen as an extension of the existing meaning of something which is small and irritating (the possible presence of surveillance bugs acts as a detriment to free speech in any context). See bugging.