Viruses that selectively target and kill bacteria — also known as bacteriophages or simply phages — infect bacteria but leave human cells alone. Once they attach to a bacterial cell, they inject their genetic material, hijack the cell's machinery and force it to produce new phages until the bacterium bursts.
The problem is that bacteria can evolve defences against phages, just as they evolve resistance to antibiotics.