A nut is a type of fastener with a threaded hole. Nuts are almost always used in conjunction with a mating bolt to fasten multiple parts together. The two partners are kept together by a combination of their threads' friction, a slight stretching of the bolt, and compression of the parts to be held together.
An M4 nut threaded onto an Allen key socket head screw
Nuts come in many sizes. This one is part of the Sydney Harbour Bridge.
Left to right: Wing, hex, hex flange, and slab weld nuts.
Left to right: Slotted, square (upper), T-nut (lower), cap (or acorn), nylon locking (top and side views), and castellated nuts.
A fastener or fastening is a hardware device that mechanically joins or affixes two or more objects together. In general, fasteners are used to create non-permanent joints; that is, joints that can be removed or dismantled without damaging the joining components. Steel fasteners are usually made of stainless steel, carbon steel, or alloy steel.
Typical fasteners (US quarter shown for scale)
Structural bolt DIN 6914 with DIN 6916 washer and UNI 5587 nut