This quick instructable will teach you how.
You will need:
1) Buttonhole thread (Professional shops normally use Silamide type A thread sold in small 40 yard cards in any beading store or $1 each on ebay/Etsy). I stock the basic 5 colors: white, tan, brown, gray, and black which pretty much covers everything that comes up.
3) Needle (John James needles are considered the best on the market. You can buy a 100 professional pack for $5.00 on Amazon which will probably last you your whole life or any sewing store. 3-5 will generally run you under $2. These are GREAT.)
4. Button to be sewn on
5. Article of clothing to be repaired or finished