Can I use machine screws in wood to hang shelves?
No. Wood needs wood screws.



These have a sharp point for piercing wood and a deeper thread than machine screws (often called bolts). The shallower thread on bolts is fine for metal, but not for wood.

For ease in setting a deep screw, you should also pre-drill the holes with a bit slightly thinner than the shaft of the screw. And for shelf brackets, I would use long screws, at least 2+ inches beyond the bracket and the drywall.

Take comfort in the fact that screws in studs are much stronger than bolts and toggles in drywall.

(All of the above assumes that there are not contrary instructions that came with the shelf mounting brackets.)

 Images and links are illustrative only, not an endorsement of goods or sources.