These are known as commensal bacteria. Others, particularly those in our gut, obtain nutrients from us, but also help us to break down food and protect us from 'bad bacteria'. These are known as symbiotic, or 'good bacteria. Bad bacteria are those which do us harm.
I low-key don't know if I answered this right but here you go!