A virus infects the cell by attaching fibers of its protein tail to a specific receptor on the bacterial cell wall and then injecting the nucleic acid into the host, leaving the empty capsid outside.
In viruses with a membrane envelop, the viral envelop merges with the host cell membrane and is taken in to the host cell by a process called pinocytosis, then releases its nucleic acid inside the host cell to be intergraded with host cell genome.