Bacteria may be autotrophic or heterotrophic.
Some bacteria are autotrophic like Cyanobacteria (blue green algae) as they synthesise their own food.
Some bacteria may be heterotrophic like Salmonella, Bacillus etc because they depend on other organisms like animals or plants for food.