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 (with slight elastic deformation), a slight stretching of the bolt, and compression of the parts to be held together.
Most nuts are installed with a wrench, socket or driver, but certain types, such as knurled and wing nuts, are installed by hand. In environments subject to vibrations, lock nuts can add extra tension to an assembly to prevent accidental back off. For the most part, standard hex nuts work well with many household applications.
Square nuts were the standard in the past due to their ease of manufacturing, but as methods of making nuts has progressed the six-sided hex nut has become the standard nut. A six-sided nut allows for more entry points on the nut. This allows a wrench to work more efficiently in tight spaces. Square nuts are still used today in situations where extreme torque is required. Four sides have a much higher tolerance against stripping than their six sided sibling.