Hair is a collection of filaments of dead cells that grow on the skin of animal lifeforms, 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. From an evolutionary standpoint, hair and fur are an adaptation to provide sensory information, protection and temperature control.
Humanoids recognize different arrangements of hair common to many civilizations, such as beards and mustaches.
History and specifics
Many sentient lifeforms have societal, cultural and aesthetic reasons for growing and styling hair in certain fashions, as a display to communicate personal identity and so on. In and around the Federation, the services of a barber can be retained to cut and maintain a hairstyle, in a barbershop or salon.
Some Human members of Starfleet have a practice of coloring their hair, such as 23rd century paramedic Savannah Ring and 24th century command division officer Christine Vale. Notably, both were indecisive about preferring a specific color, and they would often make drastic changes. (TOS - New Earth novel: Challenger; TNG - A Time to... novel: A Time to Be Born, TTN novels: Orion's Hounds, Sword of Damocles, Over a Torrent Sea, Synthesis)
On a Delta Quadrant planet near Talax, on the plains of Central 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")
In the primary universe, Vulcan males did not often 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. However, this did not stop some Vulcans from growing beards. One famous Vulcan that maintained a full beard was Sybok. His half brother, Spock, wore a beard for a time in 2257, but by 2265, had shaved it off again. In the mirror universe, however, bearded Vulcans were much more common, with Spock and Soval being notable examples.
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.. Many green Orion men of the 22nd century were entirely bald. 
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 2365, Commander William T. Riker decided to grow a beard, after tiring of people commenting on how young he looked. While on shore leave, he allowed his beard to grow, and upon returning to the USS Enterprise trimmed and styled the beard. Riker kept the beard for a number of years, but shaved it off in 2375.
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, Thomas Riker shaved off most of his beard, and maintained a goatee instead, to further differentiate himself from William Riker.
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")
A mustache is facial hair located above the upper lip, under the nose.
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)
- TOS novel: Probe
- VOY episode: "Gravity"
- TOS movie: Star Trek V: The Final Frontier
- DSC episode: "Light and Shadows"
- TOS episode: "Where No Man Has Gone Before"
- TOS episode: "Mirror, Mirror"
- ENT episode: "In a Mirror, Darkly"
- FASA RPG module: The Orions: Book of Common Knowledge
- ENT episodes: "Borderland", "Bound"
- TNG episode: "The Pegasus"
- TNG novel: Strike Zone
- TNG movie: Star Trek: Insurrection
- TNG episode: "Second Chances"
- DS9 episode: "Defiant"
- TOS novel: A Contest of Principles
- VOY - Myriad Universes - Infinity's Prism novella: Places of Exile