You can buy stuff like Petromalt, which helps them pass hairballs and not vomit them up. I used that for some 10 years until I found Pet Talk!

The directions suggest you put a small pearl sized amount on a paw and let the cat lick it. Do that a few times per week at first, once per week on a regular basis. However, my cats just flicked their paw and sent the drop flying across the room. So I would smear it on the upper lip, and let them lick it from there to clean up. It helped.

Now I have found a food which does all that and I don't need to use a supplement. (Chicken Soup for the Cat Lover's Soul)

Hairballs are common in cats, particularly long haired ones.

Best wishes!