Bacteria can thrive on almost anything and adapt themselves to very diverse environments. They can eat subsist on substances like cellulose which we humans cannot assimilate. They can breakdown poisonous gases like hydrogen sulfide and absorb nitrogen from atmosphere and fix them into the roots of many plants which plants use as fertilizer.
Bacteria can even breakdown crude oil. Crude oil consists of millions of hydrocarbons which are composed from carbon and hydrogen. These compounds range from the simplest molecule called methane made from 1 carbon atom to giant molecules containing even more than 50 carbon atoms.
Many of these bacteria live in the upper crust of the soil. They have attained the capability to use lighter hydrocarbon gases namely methane, ethane, propane and also the higher molecular hydrocarbons as the source of the carbon nutrient for energy. These are called aerobic bacteria and commonly termed as methanotrophs, propanotrophs and so on. They use like us the atmospheric oxygen to oxidize the hydrocarbons and end result is energy, carbon dioxide and water, the same products as are generated during the digestion of food by us. Of course, they also need so many other nutrients like electrolytes, trace elements which they use to synthesize enzymes which help in carrying out degradation reactions at much lower temperatures.
But this is not the end of story. There are bacteria which can survive in the anoxic (without oxygen) environment such as deeply buried bacteria which breakdown the organic matter. They extract the oxygen required to breakdown the organic matter from the sulfate ions present in the water associated with the organic matter. They breakdown the organic matter to methane and one strain of them is aptly called methanogens.
One may wonder if such bacteria exist deep down and breakdown the oil why have they eaten up all the oil present inside the reservoirs. The answer is that they are sloths in nature. They multiply with speeds nowhere near to the aerobic bacteria. Experimenters working in proliferating and separating the pure strains are often frustrated with there laziness.
The hypothesis that all the biogenic gas has been produced by aerobic bacteria is being challenged because biogenic gas has been found in the deeper sediments generated under anaerobic conditions. Researchers say that the methane trapped inside the ice crystals called gas hydrates has been the handiwork of methanogens.