Hair is a collection of filaments of dead cells that grow on the skin of animals, usually mammals. Typically, hair on humanoids usually grows on top of the head, and can be styled for cultural or aesthetic reasons. On mammalian animals, hair is usually referred to as fur. Humanoids recognize different arrangements of hair common to many civilizations, such as beards and mustaches.
On the Delta Quadrant planet Tarkanna, the native Tarkannans would collect the edible hair follicles of the Alfarians every autumn to make Alfarian hair pasta out of them. (ST reference: Star Trek Cookbook)
A beard is the facial hair that grows on the face of most humanoid males - including humans, Vulcans, Klingons, and Bajorans. Some males choose to grow full beards, other males do not grow full beards or only grow partial beards, and control the growth of beards by shaving or through the use of a beard suppressant.
At various points in history, those with beards were associated with the positive qualities of wisdom, virility, or being of refined character. At other times, those with beards were seen to have negative attributes - such as a lack of cleanliness or eccentricity. Dr. Beverly Crusher felt that with the availability of razors that beards were an affectation. (TNG episode: "The Quality of Life")
Vulcan males did not generally wear beards. Vulcans had a saying that "A beard often reveals more than it conceals," feeling that a male with a beard had something to hide (TOS novel: Probe). However, this did not stop some healers and masters from growing beards (VOY episode: "Gravity"). One famous Vulcan who maintained a full beard was Sybok (Star Trek V: The Final Frontier). In the mirror universe, however, bearded Vulcans were much more common, with Spock and Soval being notable. (TOS episode: "Mirror, Mirror", ENT episode: "In a Mirror, Darkly")
Orions had mixed attitudes to hair. Some green Orions, both men and women, held body hair to be a mark of distinction, and tended to be quite hairy. On the other hand, Ruddy Orions felt that body hair was "disgusting" and chose to shave it all off, choosing to wear wigs instead (FASA RPG module: The Orions: Book of Common Knowledge). However, many green Orion men of the 22nd century were entirely bald. (ENT episodes: "Borderland", "Bound")
After Dr. Leonard McCoy left Starfleet following the first five-year mission on the USS Enterprise, he took the time to grow a full beard. However, shortly after returning to Starfleet when the refitted Enterprise was launched, Dr. McCoy shaved his beard. (TOS movie & novelization: The Motion Picture)
In the 24th century, Commander William T. Riker decided to grow a beard in 2365 after tiring of people commenting on how young he looked. (TNG episode: "The Pegasus") While on shore leave, he allowed his beard to grow, and upon returning to the USS Enterprise trimmed and styled the beard. (TNG novel: Strike Zone). Riker kept the beard for a number of years, but shaved it off in 2375. (TNG movie: Star Trek: Insurrection)
Riker's transporter duplicate Thomas Riker also grew a beard while trapped on Nervala IV. After being rescued by the Enterprise and learning of William Riker's existence, (TNG episode: "Second Chances") Thomas Riker shaved off most of his beard, and maintained a goatee instead, to further differentiate himself from William Riker. (DS9 episode: "Defiant")
Shortly after Commander Riker grew his beard, Lt. Commander Data also decided to experiment with growing his own beard. After seeing the reaction of Lieutenant Geordi LaForge and Deanna Troi to what he had called his "new look", Data decided not to keep it. (TNG episode: "The Schizoid Man")
In 2270, Hikaru Sulu grew a mustache after being encouraged to by a friend, Lieutenant Commander Mandala Flynn. In an alternate timeline caused by a scientist experimenting in time travel, Sulu was wearing the mustache when assigned to the USS Aerfen after the Enterprise was called to transport the scientist to answer for his crimes. When the scientist, Georges Mordreaux, was prevented from changing history, the ship was not diverted and Sulu never had the opportunity to transfer. As the mission continued, Captain James T. Kirk shared that he himself had not been able to tolerate the look of his own face with a mustache, since it had grown in a much redder color than the rest of his hair. Sulu eventually decided to shave his own mustache. (TOS novel: The Entropy Effect)