I've heard people say that greetings from before, and I picked it up from them. I was wondering if it is a legal sentence and its origin.
Whether or not one hears how do commonly may be a matter of locale. English is pronounced, mispronounced, and generally mauled differently in each corner of the world where it is spoken.
I have heard the greeting how do? at least three times since yesterday noon in rural NE US.
It is, as others have said, a shortening of "How do you do."
Although one can parse the parent phrase into a grammatically complete (if slightly ridiculous) sentence, in which the subject you performs the intensified verb do do which is modified by the adverb how, the exercise in doing so would be purely academic doodoo, as in all probability few if any greeters have truly wished to know how, in fact, someone else does do, did do or has done doing since the 18th century.
Instead, the phrase falls into the category of phatic expressions. All hail Wikipedia:
In linguistics, a phatic expression is one whose only function is to perform a social task, as opposed to conveying information. The term "phatic communion" was coined by anthropologist Bronislaw Malinowski in his essay "The Problem of Meaning in Primitive Languages," which appeared in 1923 in The Meaning of Meaning by C.K. Ogden and I.A. Richards. The term comes from the Greek "phatos" (spoken, that may be spoken), and from "phanai" (to speak, say).
Like other phatic expressions (e.g. Hi, Hey, Yo, and Heighdy-Ho) it neither needs nor wants grammatical analysis.
It is an old Saturday Western form of greeting, something you might have heard while watching a Roy Rogers western, or perhaps a wannabe Gone With the Wind Southern picture. I'm sure I've heard it a few dozen times in old movies.
Basically it's a very informal version of "How do you do?" (Imagine the cowboy tipping his dusty hat to the lady as he says it.)
I suppose it may still be in use (if it ever was) in the Western US, but it's not a common idiom.