How do you do? is a bit formal sounding; at least here in the U.S., we'd usually use the more informal How are you? instead.
How are you? (or, even more informally, How ya' doin'?) is indeed used as a greeting as often as it is as a genuine inquiry, although there are, of course, some exceptions. If I had been in an accident, for example, and was paid a visit as I was laying in my hospital bed, I would not answer "How are you doing?" with another "How are you doing?" Instead, I'd assume the person wanted to know how I was feeling after the accident. However, when I pass someone in the hallway at work, it's not uncommon for one "How're you doing?" to be answered with another, as if we had said "Hello" instead.
Of course, this generalization can vary somewhat based on region and local culture, a fact that was brilliantly parodied in this commericial, where the visitor doesn't seem to recognize that, at least in New York, "How ya' doin'?" is not usually an open-ended question (as it might be in Texas, where the visitor is apparently from).
Usually, when "How are you doing?" is given as an answer to "How are you doing?", that's done among friends and close acquaintances. However, when being introduced to someone for the first time, we generally answer the question, rather than repeat the question, as Bill said in his comment:
How are you doing?
Fine, thanks – and you?
Something like that would probably be the "safest" response if you weren't sure what to say.